D
dsmith
Using Visual Studio Express 2008.
I've built a program that uses an SQL/CE database (v.3.5), and
constructed a strongly-typed dataset (.xsd) based on that database.
One of the fields is an Int32 value. It's set as AllowDBNull = false
(in both VS designer and database), and a default value of 0.
When I tried to enter a new record into this table and update it (call
the UpdateAll on the TableManager class once all the table adapters
have been set up) it throws an exception saying that "The column
cannot contain null values. [ Column name = //column//,Table name = //
table// ]". The datarow was created with an explicit value of 0 set
for that column.
As I understood it, 0 is not the same as DBNull, therefor this
shouldn't be happening. Am I mistaken, and that I'm required to allow
Nulls in any int column that can possibly be 0? If I allow nulls in
this column, everything seems to work ok (though I had another bug
while testing, saying that the value was null when trying to iterate a
Sum() on it, which is why I tried to change it back again).
I've built a program that uses an SQL/CE database (v.3.5), and
constructed a strongly-typed dataset (.xsd) based on that database.
One of the fields is an Int32 value. It's set as AllowDBNull = false
(in both VS designer and database), and a default value of 0.
When I tried to enter a new record into this table and update it (call
the UpdateAll on the TableManager class once all the table adapters
have been set up) it throws an exception saying that "The column
cannot contain null values. [ Column name = //column//,Table name = //
table// ]". The datarow was created with an explicit value of 0 set
for that column.
As I understood it, 0 is not the same as DBNull, therefor this
shouldn't be happening. Am I mistaken, and that I'm required to allow
Nulls in any int column that can possibly be 0? If I allow nulls in
this column, everything seems to work ok (though I had another bug
while testing, saying that the value was null when trying to iterate a
Sum() on it, which is why I tried to change it back again).