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

Checking DataSet value for null

P: n/a
How can I check this for null? dsPrsn.Tables(0).Rows(0)("WORK_STATE")
I tried If IsDbNull(dsPrsn.Tables(0).Rows(0)("WORK_STATE")) Then it seems
not too work. I am attempting to check this field in my data set to see if
it is null or not. If it is null I want to set my drop down list to a
certain value (where I'm using dropdown.SelectedValue = ). If it is not
null I want to set the drop down to the dataset value. Here is what the
login/code should be...

If IsDBNull(dsPrsn.Tables(0).Rows(0)("WORK_STATE")) Then

cmbState.SelectedValue = 'some value

Else

cmbState.SelectedValue = dsPrsn.Tables(0).Rows(0)("WORK_STATE")

End If

THANKS!!!
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Andy, check out dbnull.value, e.g. vb syntax "if object is dbnull.value" - Bill

"Andy G" wrote:
How can I check this for null? dsPrsn.Tables(0).Rows(0)("WORK_STATE")
I tried If IsDbNull(dsPrsn.Tables(0).Rows(0)("WORK_STATE")) Then it seems
not too work. I am attempting to check this field in my data set to see if
it is null or not. If it is null I want to set my drop down list to a
certain value (where I'm using dropdown.SelectedValue = ). If it is not
null I want to set the drop down to the dataset value. Here is what the
login/code should be...

If IsDBNull(dsPrsn.Tables(0).Rows(0)("WORK_STATE")) Then

cmbState.SelectedValue = 'some value

Else

cmbState.SelectedValue = dsPrsn.Tables(0).Rows(0)("WORK_STATE")

End If

THANKS!!!

Nov 19 '05 #2

P: n/a
Did you want to check for a null value instead? Null and DBNull are
technically different values. Try If ... Is Nothing to test for null.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 9 Feb 2005 14:40:48 -0600, "Andy G" <aj*****@iastate.edu>
wrote:
How can I check this for null? dsPrsn.Tables(0).Rows(0)("WORK_STATE")
I tried If IsDbNull(dsPrsn.Tables(0).Rows(0)("WORK_STATE")) Then it seems
not too work. I am attempting to check this field in my data set to see if
it is null or not. If it is null I want to set my drop down list to a
certain value (where I'm using dropdown.SelectedValue = ). If it is not
null I want to set the drop down to the dataset value. Here is what the
login/code should be...

If IsDBNull(dsPrsn.Tables(0).Rows(0)("WORK_STATE")) Then

cmbState.SelectedValue = 'some value

Else

cmbState.SelectedValue = dsPrsn.Tables(0).Rows(0)("WORK_STATE")

End If

THANKS!!!


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.