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();
}

原文地址:https://www.cnblogs.com/grj001/p/12225667.html