Monday 23 June 2008

DBNull

I keep having to google this bad-boy every time it comes up so thought I'd make a note of it here.

Let's say you've got a custom object which is populated using a DataReader, unless you've got a crystal ball it's quite likely that you will end up with some NULL values in your database. Here's what to do about it:

If Not IsDBNull(rdr("Telephone")) Then

m.Tel = rdr("Telephone")
Else

m.Tel = ""
End If

No comments: