469,641 Members | 1,164 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

checking for a null in a bit datatype field

Hi,

I have an SQL Query that loads a SQLDataReader object.

The returned record has bit datatype columns that I use to provide
true/false values.

I can't get a definite answer googling on how to test if this field is null.

I get casting errors, and can't check for null on a null data value errors
messages.

can someone point me to a definite article on checking for nulls using an
SQLDataReader

or

the code (C#) on testing for null value?

thanks

Chris
Nov 17 '05 #1
2 3207
Check it against System.DBNull.Value. That will give the desired results.

"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:3C**********************************@microsof t.com...
Hi,

I have an SQL Query that loads a SQLDataReader object.

The returned record has bit datatype columns that I use to provide
true/false values.

I can't get a definite answer googling on how to test if this field is null.
I get casting errors, and can't check for null on a null data value errors
messages.

can someone point me to a definite article on checking for nulls using an
SQLDataReader

or

the code (C#) on testing for null value?

thanks

Chris

Nov 17 '05 #2
Ron
Your instance of SqlDataReader has a function for that purpose: IsDBNull.

"Chris" wrote:
Hi,

I have an SQL Query that loads a SQLDataReader object.

The returned record has bit datatype columns that I use to provide
true/false values.

I can't get a definite answer googling on how to test if this field is null.

I get casting errors, and can't check for null on a null data value errors
messages.

can someone point me to a definite article on checking for nulls using an
SQLDataReader

or

the code (C#) on testing for null value?

thanks

Chris

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Roger Withnell | last post: by
1 post views Thread by Jamie Burns | last post: by
4 posts views Thread by subaruwrx88011 | last post: by
4 posts views Thread by Patient Guy | last post: by
3 posts views Thread by Jay | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.