By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,905 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,905 IT Pros & Developers. It's quick & easy.

Null insert problem

P: n/a
Hi everyone,

We can not set an integer value as null, since it's a value type.

We want to insert this integer value to a DataTable which has an integer
column. (And then update the database..)

How can we achieve to write null to the dataTable or at least to database?

Thanks,

Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
aculfa,

You should be able to set the column value for the row to the static
Value property on the DbNull class. This should make it null. Either that,
or create a new instance of the SqlInt32 structure and set the IsNull
property to true.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"aculfa" <a.*****@belbim.com.tr> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi everyone,

We can not set an integer value as null, since it's a value type.

We want to insert this integer value to a DataTable which has an integer
column. (And then update the database..)

How can we achieve to write null to the dataTable or at least to database?

Thanks,

Nov 15 '05 #2

P: n/a
"aculfa" <a.*****@belbim.com.tr> writes:
How can we achieve to write null to the dataTable or at least to database?


Take a look to NullableTypes

http://nullabletypes.sourceforge.net/

FAQ: http://nullabletypes.sourceforge.net/sqltypes.html

--
Lawrence "Rhymes" Oluyede
http://loluyede.blogspot.com
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.