当用户输入姓名的一栏,则取数据库中校验是否有当前输入的姓名,如果数据库有当前输入的姓名,则在会员编号那一栏显示出相对应的会员编号。
求源码
把姓名作为sql查询参数,查询出数据来,再绑定至其他控件上。
//伪代码大致如下
SqlConnection connection = new SqlConnection("连接字符串");
SqlDataAdapter sda = new SqlDataAdapter("select from table name where name = '"+textbox1.text+"'",connection);
DataSet ds = new DataSet();
sda.Fill(ds);
if(ds.Tables[0].Rows.Count != 0)
{
textbox2.Text = ds.Tables[0].Rows[0]["no"];
}
你也可以使用EntityFrameWork作为orm框架来操作数据库。