C#如何以TEXTBOX控件中输入的内容查找数据库其他内容

查询加上条件即可。
SqlConnection cn = new SqlConnection();
cn.ConnectionString = "server=.;database=yourdb;uid=sa;pwd=pwd";
cn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "select regdate from yourtable where carNO=@no";
cmd.Parameters.AddWithValue("@no",textBox1.Text.Trim());
var date = cmd.ExecuteScalar();
cn.Close();
if(date!=System.DBNull.Value )
{
this.textBox2.Text = date.ToString();
}

posted @ 2019-01-03 08:23  grj001  阅读(593)  评论(0编辑  收藏  举报