这是查询的代码,现在报错"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();大家帮我看看,可能代码本身没有问题,应该以前我运行正常的

解决方案 »

  1.   

    检查下da.Fill(table);中的table,看看对不对
      

  2.   

    table 是我在da.Fill(table)前面定义的,看起来没错啊
      

  3.   

    看看数据库里的record表是怎么定义的
    每个列的数据类型,有没有是int型的你拿来当nvchar用了
    仔细对照一下
      

  4.   

    string strsql="select * from record where ID LIKE '"+textBox1.Text+"%"+"'AND name LIKE '"+textBox2.Text+"%"+"'AND datetime LIKE '"+textBox3.Text + "%"+"' gunid LIKE '"+textBox4.Text + "%"+"";
    =====
    语句估计有问题
      

  5.   

    string strsql="select * from record where ID LIKE '"+textBox1.Text+"%"+"'AND name LIKE '"+textBox2.Text+"%"+"'AND datetime LIKE '"+textBox3.Text + "%"+"' gunid LIKE '"+textBox4.Text + "%"+"";"'and 应该为: "' and
    "+"' gunid  应该为:"+"' and gunid 另外对于匹配较常用的是: %value%是两边带%号的,你这种匹配只能匹配某某值开头的形式
      

  6.   

    如果以前运行正常,估计是Sql里的传入值是不是有问题。
    跟踪一下Sql语句,最好用查询分析器看看