Solved

Checking for null values in date columns coming from SQLSERVER 2000

Posted on 2004-10-19
1
222 Views
Last Modified: 2010-04-23
Hey,  I am retrieving data from sqlServer 2000 with ADO.NET using the dataReader. I have the following statement:
If myReader.IsDBNull(9) = False Then
    UpdateRequest.RenewalDT = myReader.GetDateTime(9).ToShortDateString     'Renewal Date
Else
    UpdateRequest.RenewalDT = String.Empty
End If

I get the following message:
System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.

What is the best way to check the datatime column for null values?

Thanks,

Joe
0
Comment
Question by:courchjo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
ndonhauser earned 500 total points
ID: 12349473
If myReader(9) is DBNull.Value Then
    UpdateRequest.RenewalDT = String.Empty
Else
    UpdateRequest.RenewalDT = myReader.GetDateTime(9).ToShortDateString     'Renewal Date
End If

Good Luck.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question