这是查询的代码,现在报错"da.Fill(table)"
说是未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。其他信息: 系统错误。string strsql="select * from record where ID LIKE '"+textBox1.Text+"%"+"'AND name LIKE '"+textBox2.Text+"%"+"'AND datetime LIKE '"+textBox3.Text + "%"+"' gunid LIKE '"+textBox4.Text + "%"+"";
sqlConnection1.Open();
SqlDataAdapter da=new SqlDataAdapter(strsql,sqlConnection1);
DataTable table = new DataTable("record");
da.Fill(table);
dataGrid5.DataSource=table;
sqlConnection1.Close();大家帮我看看,可能代码本身没有问题,应该以前我运行正常的
说是未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。其他信息: 系统错误。string strsql="select * from record where ID LIKE '"+textBox1.Text+"%"+"'AND name LIKE '"+textBox2.Text+"%"+"'AND datetime LIKE '"+textBox3.Text + "%"+"' gunid LIKE '"+textBox4.Text + "%"+"";
sqlConnection1.Open();
SqlDataAdapter da=new SqlDataAdapter(strsql,sqlConnection1);
DataTable table = new DataTable("record");
da.Fill(table);
dataGrid5.DataSource=table;
sqlConnection1.Close();大家帮我看看,可能代码本身没有问题,应该以前我运行正常的
每个列的数据类型,有没有是int型的你拿来当nvchar用了
仔细对照一下
=====
语句估计有问题
"+"' gunid 应该为:"+"' and gunid 另外对于匹配较常用的是: %value%是两边带%号的,你这种匹配只能匹配某某值开头的形式
跟踪一下Sql语句,最好用查询分析器看看