请教一下,我想将combobox和textbox组合使用,通过combobox查询到的设备类别,在此基础上,textbox内输入设备参数,将查询的结果体现到datagridview表格里面,请问这个语句怎么写呢,以下是我已写的语句,能够查询到第一步设备类型了;
private void button1_Click(object sender, EventArgs e)
{
conn = new SqlConnection("server=IP;database=ERP;user=sa;password=12345");
conn.Open();
//查询条件
SqlString = "select EquipmentName,CreateTime,ParamsName,Value from b_HistoricalData where Equipmentname = '" + comboBox1.Text + "' "; //配置了与下拉列表绑定,按其查询分类显示;
//加载数据并显示
try
{
//查询条件和SqlConnection连接
SqlCommand cmd = new SqlCommand(SqlString, conn);
//数据适配器
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
//DataTable存储数据
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
catch
{ }
finally
{
conn.Close();
}