Solved

Checking for null values in date columns coming from SQLSERVER 2000

Posted on 2004-10-19
1
210 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 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