Checking DataSet value for null

A

Andy G

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!!!
 
S

Scott Allen

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.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top