|
-
Mar 22nd, 2006, 07:49 AM
#1
Thread Starter
Member
[RESOLVED] Dealing with Nulls using the Datareader method...
Hello all,
I am after advice on the best method to deal with nulls returned from the DB when using the datareader method for gathering my data.
Here is a sample of my code:
'See if any data exists before continuing
If objData.DataReader.HasRows Then
'Read the first and only row of data
objData.DataReader.Read()
txtFirstName.Text = _
objData.DataReader.Item("FirstName").ToString.ToUpper
txtSurname.Text = _
objData.DataReader.Item("LastName").ToString.ToUpper
End If
I get an error when this code is run along the lines of 'cannot cast DBNull to string'.
Now I can sort out Nulls at the DB end, no problem, but I would prefer to do this at the client end.
I've looked into the IsDBNull function but just cannot get that to work for some reason. Can someone shine any light on this please?
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|