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