datagrid checkbox writes Null instead of 0 (false)

2019-08-17 04:00发布

I have a Table in my sql-database that has the following fields: Name(string), Quartal1(bit), Quartal2(bit), Quartal3(bit), Quartal4(bit).

I bound that Table to a datagrid (winform in visual studio). I have a Checkbox for every Quartal and save the dataset into my database. It works actually it writes a 1 for checked into my database BUT it writes a NULL instead of a 0 (for false) into my database for unchecked. I tried to change the "FalseValue" & "TrueValue" property to "FALSE" and "TRUE" or "0" and "1" but it doesnt help. I also changed the field property "NULLS ALLOWED" to "NULLS NOT ALLOWED" but that didnt help as well. Since i need a 0 for not checked i need your help to accomplish that.

1条回答
姐就是有狂的资本
2楼-- · 2019-08-17 04:37

Ok, it didnt work. What helped was that i created a new dataset and used the designer-view. Here you can set a default value (default was something like ) to the one i needed (in this case 0). Now it writes the value into the database.

查看更多
登录 后发表回答