473,715 Members | 6,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3404
Check it against System.DBNull.V alue. That will give the desired results.

"Chris" <Ch***@discussi ons.microsoft.c om> wrote in message
news:3C******** *************** ***********@mic rosoft.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
2947
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 and varchar but not for datatype image, although there is no error - the image field still contains the image! I'm using SQL server and running an UPDATE statement including image = NULL works.
1
14774
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 returning the default values for that table instead of NULL's, in a portable way?
1
2482
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. Function DateCalc (blah...) As Variant Do Stuff... If Not IsNull(varNewDate) Then DateCalc = varNewDate End If End Function
1
10440
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 getting the following error: DBD::Pg::st execute failed: ERROR: invalid input syntax for type date: "null" I also get the exact same error if I attempt to insert an empty string
4
2300
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<tab>Hello World<tab>NULL<tab>5.56 1) Is this a correct way to make sure that this field will be NULL
1
1982
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 to make use of SQL Server 2005s XMLData type. To do this I have created a new field of the 'xmldata' datatype, and run an SQL statement to update the contents from one field to another - hoping to end up with a complete table of xml (based on...
4
2382
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 exceptions?
3
4596
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 data to a web service and it accepts only date (datatype). I dont want to display 01/01/0001 on the screen. I want to leave the date field as "blank". Are there any suggestions to work around this problem. thanks Jay
1
1277
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 while updating it is giving error converting varchar to datetime how to store NULL in that field please respond Thanks in Advance
0
8823
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2119
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.