代码:
1、链接数据库
SqlDataAdapter da;
DataTable dt;
private static readonly string SQL = ConfigurationManager.AppSettings["connectionstring"];
2、在需要搜索编号的textbook中找到KeyDown属性,双击,代码如下
string aa = textBox1.Text.Trim();
string str = "select contractid as 合同编号,company as 客户,seller as 业务员,sub as 区域,date as 日期,project as 项目名称,amount as 金额 from [dbo].[Contract_h] where contractid like '%" + aa + "%' ";
da = new SqlDataAdapter(str, SQL);
dt = new DataTable();
da.Fill(dt);
textBox2.Text = dt.Rows[0]["客户"].ToString();
textBox3.Text = dt.Rows[0]["业务员"].ToString();
textBox4.Text = dt.Rows[0]["区域"].ToString();
textBox5.Text = dt.Rows[0]["项目名称"].ToString();
效果
标签:Rows,Text,textbook,ToString,编号,回车键,dt From: https://www.cnblogs.com/45fdsf4s4sdfsddv/p/17845566.html