|
|
Subject:
SqlDataReader.IsDBNull Method
Category: Computers > Programming Asked by: homebuilder-ga List Price: $10.00 |
Posted:
20 Feb 2003 09:12 PST
Expires: 22 Mar 2003 09:12 PST Question ID: 163956 |
SqlDataReader.IsDBNull Method I think i need to use this to check for null values prior to using the statement "address.Value = myReader.GetString(5)" otherwise I get the error "Data is Null. This method or property cannot be called on Null values" but am unsure of the code to use it.Please could you give me an example of the required code to check for null values prior to using the getstring method Thanks | |
| |
|
|
Subject:
Re: SqlDataReader.IsDBNull Method
Answered By: cerebrate-ga on 21 Feb 2003 23:10 PST Rated: |
Dear homebuilder-ga, You're quite correct in that you need to call this method in order to check for NULL values before retrieving data through your SqlDataReader. The specific code you need to do this looks like this: If (myReader.IsDBNull (5)) Then ' Handle a NULL value, in some appropriate way. Here, I just substitute ' an empty string for the NULL. address.Value = "" Else ' Retrieve the actual value address.Value = myReader.GetString (5) End If An example of using a SqlDataReader to read information from a database, including this code, can be found by going to: http://samples.gotdotnet.com/quickstart/howto/ then scrolling down to "Data and ADO.NET", and selecting "Retrieve data from a SQLServer database". If this answer isn't quite what you're looking for, please feel free to request a clarification, cerebrate-ga Search strategy: Personal knowledge. |
homebuilder-ga rated this answer: |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |