473,395 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 3383
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Roger Withnell | last post by:
I'm updating a record by opening a recordset, setting the fields and the updating it with objRS.Update. I need to set an image datatype to NULL. objRS("field") = NULL works for datatypes int...
1
by: Jamie Burns | last post by:
Hello, I am trying to perform a LEFT JOIN on a table which may or may not have matching rows. If there are no matching rows, it returns NULL's for all the missing fields. Is there anyway of...
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
1
by: Smitty | last post by:
From the psql command line, I am having absolutely no problems inserting a NULL value into a date datatype field. When attempting to insert a NULL value via my Web app using SQL Relay, I am...
4
by: subaruwrx88011 | last post by:
So I pressed tab-enter and posted an incomplete topic, sorry. I have imported information into a database using a file. It is tab delimited and for NULL fields I have NULL. example file.txt...
1
by: DSmith1974 | last post by:
Hi All, Can anyone help with the following problem? I have a database which contains a table with a 'text' field, and the text field contains an xml document - typically 50-100K. Now I'd like...
4
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw...
3
by: Jay | last post by:
Hi , I am trying to assign a NULL value to a date (datatype). I am using VB NET 2003. I know that date cannot be assigned a null value in 2003. I cannot change the datatype as I am submitting the...
1
by: Vajrala Narendra | last post by:
Hi am working with asp.net with backend Sql2000 i want to store NULL in datetime datatype field through coding. i wrote a update statement as Update table set Date1='NULL' where ........ but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.