Solved

Checking for null values in date columns coming from SQLSERVER 2000

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Code enhancement 5 23
Get String split 5 48
Vb.net dynamic formulas in runtime 11 62
Point to Current Row Ater Refresh Datagridview 3 20
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now