这段是我的代码:
comstr="SELECT TOP "+this.comboBox4.Text
+ "题号,正文,参考答案 FROM 题库表 WHERE 科目 like '"+this.comboBox1.Text
+"' and 类型=2 and 难度=" +this.comboBox5.Text
+" and 章节 between "+ numericUpDown1.Value.ToString()
+" and "+numericUpDown2.Value.ToString()
+" ORDER BY NEWID()";
Command.CommandText=comstr;
Command.CommandType=CommandType.Text;
DataReader=Command.ExecuteReader();
comstr="SELECT TOP "+this.comboBox4.Text
+ "题号,正文,参考答案 FROM 题库表 WHERE 科目 like '"+this.comboBox1.Text
+"' and 类型=2 and 难度=" +this.comboBox5.Text
+" and 章节 between "+ numericUpDown1.Value.ToString()
+" and "+numericUpDown2.Value.ToString()
+" ORDER BY NEWID()";
Command.CommandText=comstr;
Command.CommandType=CommandType.Text;
DataReader=Command.ExecuteReader();
+" and "+numericUpDown2.Value.ToString()字符串类型需要加单引号
+ " 题号要加空格