Solved

Checking for null values in date columns coming from SQLSERVER 2000

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

17 Experts available now in Live!

Get 1:1 Help Now