SqlConnection conn1 = new SqlConnection(str);
conn1.Open();
SqlCommand cmd1 = conn1.CreateCommand();
cmd1.CommandText = "Select * from 学生表 where " + comboBox2.Text+ " = " + textBox1.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd1);
DataSet ds = new DataSet();
数据库中的学生表包含 学号 姓名 班级 性别 其中comboBox2.Text内容为 学号
姓名 班级 性别 textBox1.Text 为要输入的值。
为什么只能按学号查询 按其他的都不能查询呢 ?????????
conn1.Open();
SqlCommand cmd1 = conn1.CreateCommand();
cmd1.CommandText = "Select * from 学生表 where " + comboBox2.Text+ " = " + textBox1.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd1);
DataSet ds = new DataSet();
数据库中的学生表包含 学号 姓名 班级 性别 其中comboBox2.Text内容为 学号
姓名 班级 性别 textBox1.Text 为要输入的值。
为什么只能按学号查询 按其他的都不能查询呢 ?????????
cmd1.CommandText = "Select * from 学生表 where " + comboBox2.Text+ " = '" + textBox1.Text + "'";