伙计,我如何在访问数据库或任何数据库中插入复选框的值。
我尝试了任何这个 sql 语句,但它仍然给我错误:OleDbException 未处理。条件表达式中的数据类型不匹配。它指向 myData = myCommand.ExecuteReader();
请注意,allowviewpsr 是 ms 访问数据库中的布尔类型字段或带有 YES/NO 的字段。:) chkviewpsr 是 mycheckbox
SQL = "UPDATE `RUsers` SET `allowviewpsr` = '" + chkviewpsr.IsChecked.Value + "' WHERE `idnum`= '" + txtblkuserid.Text + "' AND `fullname`= '" + txtblkusername.Text + "'";
还有这个:
SQL = "UPDATE `RUsers` SET `allowviewpsr` = '" + chkviewpsr.IsChecked + "' WHERE `idnum`= '" + txtblkuserid.Text + "' AND `fullname`= '" + txtblkusername.Text + "'";
还有这个:
SQL = "UPDATE `RUsers` SET `allowviewpsr` = '" + chkviewpsr + "' WHERE `idnum`= '" + txtblkuserid.Text + "' AND `fullname`= '" + txtblkusername.Text + "'";
这是我的连接器:
myCommand.CommandText = SQL;
myCommand.Connection = MyNewOleDbConnection;
myAdapter.SelectCommand = myCommand;
myData = myCommand.ExecuteReader();
已编辑: 嗨 anandkumar 感谢快速重播我尝试了 NonQuery 但它给出了与上面相同的错误
SQL = "UPDATE `RWMUsers` SET `allowviewpsr` = '" + chkviewpsr.IsChecked.Value + "' WHERE `idnum`= '" + txtblkuserid.Text + "' AND `fullname`= '" + txtblkusername.Text + "'";
myCommand.CommandText = SQL;
myCommand.Connection = MyNewOleDbConnection;
myAdapter.UpdateCommand = myCommand;
myCommand.ExecuteNonQuery();
我的访问数据库的快照:(