By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,382 Members | 2,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,382 IT Pros & Developers. It's quick & easy.

Testing for null value in a dataset

P: n/a
PJ
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?
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
PJ
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."
Jul 21 '05 #2

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
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?
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.