1
CODE:绑定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'.
我用同样的教程编写查询造成的。那么,如果数据类型有问题,我相信即使我的插入查询不会奏效。但它工作正常,我看到我需要在我的datagridview。该错误看起来像暗示着一些简单的事情。 – lunchbox 2012-07-30 08:52:03