Testing for null value in a dataset

G

Guest

I have a dataset with a datatable that has a datacolumn of type Date. I have the following code in my application
If IsDBNull(drEmployee.DateStart) = True Then drEmployee.DateStart = Date.Parse("01-Jan-2000"
When this line runs, I get an error message "Cannot get value because it is DBNull", which of course is what I am trying to test for. The dataset was generated using VS designer from an Access database and I have not altered any settings in the XSD. The column in Access is set to "Required = no". Where am I going wrong?
 
G

Guest

I should add that I have tried setting msprop:nullValue="_null" in the XSD but then the designer comes up with an error stating "Custom tool error: Failed to generate code. System error."
 
A

Andy Gaskell

If drEmployee is strongly typed try this:
If drEmployee.IsDateStartNull() Then drEmployee.DateStart =
Date.Parse("01-Jan-2000")

If it's not try this:
If drEmployee.IsNull("DateStart") Then drEmployee.DateStart =
Date.Parse("01-Jan-2000")

PJ said:
I have a dataset with a datatable that has a datacolumn of type Date. I
have the following code in my application:
If IsDBNull(drEmployee.DateStart) = True Then drEmployee.DateStart = Date.Parse("01-Jan-2000")
When this line runs, I get an error message "Cannot get value because it
is DBNull", which of course is what I am trying to test for. The dataset
was generated using VS designer from an Access database and I have not
altered any settings in the XSD. The column in Access is set to "Required =
no". Where am I going wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top