简体   繁体   English

使用 c# 中的查询更新访问中的复选框

[英]Update checkbox in access using query in c#

I want to check the checkbox in access using a query in C#.我想使用 C# 中的查询检查访问中的复选框。

I'm using DBSQL.我正在使用 DBSQL。

I've tried this :我试过这个:

string cmdStr = "UPDATE Workers SET Manager=@Manager WHERE ID=" + worker.Worker_ID; string cmdStr = "UPDATE Workers SET Manager=@Manager WHERE ID=" + worker.Worker_ID;

        using (OleDbCommand command = new OleDbCommand(cmdStr))
        {
            command.Parameters.AddWithValue("@Manager", worker.Manager_IsAManager);
            base.ExecuteSimpleQuery(command);
        }
    }

but i got this error : "Data type mismatch in criteria expression"但我收到此错误:“条件表达式中的数据类型不匹配”

I want to know how can i do this without getting this Exception ?我想知道如何在不收到此异常的情况下执行此操作?

The field worker.Manager_IsAManager is a string , but in access is Yes/No.现场 worker.Manager_IsAManager 是一个字符串,但在访问中是是/否。

i think this is the problem.我认为这就是问题所在。

I don't want to change the data type in access to string.我不想更改访问字符串的数据类型。

I have fixed it.我已经修好了。

i've changed the field to boolean (worker.Manager_IsAManager)我已将字段更改为布尔值 (worker.Manager_IsAManager)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM