PC Review


Reply
Thread Tools Rate Thread

Can't enter int value of 0?

 
 
dsmith@datasync.com
Guest
Posts: n/a
 
      7th Jan 2008
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).
 
Reply With Quote
 
 
 
 
dsmith@datasync.com
Guest
Posts: n/a
 
      7th Jan 2008
Addendum: Using C#, if that matters.
 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      7th Jan 2008
As soon as you add a datarow to a datatable, then all the values which may
not be null have to be filled in advance

Cor

 
Reply With Quote
 
dsmith@datasync.com
Guest
Posts: n/a
 
      7th Jan 2008
On Jan 7, 12:20*am, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
> As soon as you add a datarow to a datatable, then all the values which may
> not be null have to be filled in advance
>
> Cor


Umm.. huh?

The column in question was given a value. That value was 0, as in a
literal '0' passed in as a parameter.


Anyway, finally tracked down the issue. The database/dataset
configuration was modified as I went along, but the auto-generated
Fill/Insert/Update/Delete commands didn't get updated to match the
changes to the dataset, so that particular column wasn't being sent to
the database on update. After re-generating, it appears to be working
properly.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to select cells in column enter data then press enter NP Microsoft Excel New Users 1 20th Feb 2008 04:21 PM
hitting enter or shift+enter in asp.net designer messes up html code? Sunfire Microsoft ASP .NET 2 6th Nov 2007 02:44 PM
Enter multiple numbers in a cell so total shows when enter keypres =?Utf-8?B?bmV3Ymll?= Microsoft Excel Worksheet Functions 2 19th Aug 2007 12:23 PM
What does hitting Ctrl + Shift + Enter to enter a formula do??? Help a n00b out. qwopzxnm Microsoft Excel Worksheet Functions 2 20th Oct 2005 09:06 PM
Enter user name, enter password, then press enter... =?Utf-8?B?UGF1bCAoRVNJKQ==?= Microsoft Access Forms 6 11th Jul 2005 05:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:25 AM.