如何通过在Winform中的特定文本框中键入值来将SQL Server数据库中的表中的值检索到文本框中

问题描述:

嗨codeproject
我有一个包含三个文本框的表单,分别是名称,年龄和薪水,现在我希望当用户输入他的名字时,在该名称文本框上,他的年龄和薪水应从数据库检索到各自的文本框.在此先谢谢您

Hi codeproject
i have a form with three textboxes which are name, age and salary, now i want that when a user enter his name, on the name textbox his age and salary should be retreived from the database to their respective textboxes. Thanks in advance

,您必须使用查询
从数据库中搜索数据. 示例:从tblname中选择*,其中的名称类似于"+ textbox.text +"''

在数据表中获取此数据

将此数据分配到txtage.text = dt.rows [0] ["age"].tostring();
此名称应该在名称文本框的textchanged事件上启用.

您也可以通过javascript进行此操作.

将name的文本框值发布到Web服务并从那里获取数据.并像上面一样填充到您的文本框中
从网络服务返回字符串,并在ajax帖子中将它们拆分为薪水和年龄
you have to search data from database with where query
example : select * from tblname where name like ''"+ textbox.text+"''

get this data in datatable

assign this data into txtage.text=dt.rows[0]["age"].tostring();
this alll should be on on textchanged event of name textbox.

You can also do this by javascript.

post textbox value of name to the web service and get data from there. and fill into your textbox like above
return string from webservice and split them as salary and age in ajax post