查询中缺少databinding oledb异常运算符



代码:

//this is in private void Form3_Load(object sender, EventArgs e)
{string sql = "select * from doctofact WHERE (([doctofact].[docid]=" + l + " and     [doctofact].[1userid]='"+str6+"'))";
  da = new OleDbDataAdapter(sql, con);
        cmd = new OleDbCommandBuilder(da);
        dt = new DataTable();
        BindingSource dsource = new BindingSource();
        dsource.DataSource = dt;
        da.Fill(dt);
        dataGridView1.DataSource = dt;
          dataGridView1.ReadOnly = true;

        da.Update(dt);
      }

  private void button3_Click(object sender, EventArgs e) // edit button
    {
        dataGridView1.ReadOnly = false;
        MessageBox.Show("Click on the cell you want to edit and change");
     }

      private void button4_Click(object sender, EventArgs e) //save button
    {
        da.Update(dt);
        MessageBox.Show("The changes you made have been saved!");
    }

现在,我的datagridview显示了我想要的确切内容,所以这只是意味着查询"sql"运行良好。只有当我编辑并尝试通过单击保存按钮进行绑定时,才会出现问题。我得到的错误是:

 oledb exception missing operator in the query Syntax error (missing operator) in query expression '(((? = 1 AND DocID IS NULL) OR (DocID = ?)) AND ((? = 1 AND FactID IS NULL) OR (FactID = ?)) AND ((? = 1 AND ArticleTitle IS NULL) OR (ArticleTitle = ?)) AND ((? = 1 AND FactPreview IS NULL) OR (FactPreview = ?)) AND ((? = 1 AND 1userid IS NULL) OR (1user'.

我建议您浏览此链接。检查此链接

该问题是由数据类型不匹配引起的

最新更新