C# 查询中缺少数据绑定oledb异常运算符
代码: 现在,我的datagridview正好显示了我想要的内容,因此它只是表示查询“sql”工作正常。只有当我通过单击“保存”按钮编辑并尝试绑定时,问题才会出现。我得到的错误是:C# 查询中缺少数据绑定oledb异常运算符,c#,data-binding,datagridview,oledbconnection,C#,Data Binding,Datagridview,Oledbconnection,代码: 现在,我的datagridview正好显示了我想要的内容,因此它只是表示查询“sql”工作正常。只有当我通过单击“保存”按钮编辑并尝试绑定时,问题才会出现。我得到的错误是: //this is in private void Form3_Load(object sender, EventArgs e) {string sql = "select * from doctofact WHERE (([doctofact].[docid]=" + l + " and [doctofac
//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中看到我需要什么。这个错误似乎暗示了一些简单的事情。
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'.