Cast from type DBNull to type String is not valid
I have an application where I am filling text boxes with data from a table. Every now and then, not all the fields in the table are going to contain data. For instance some records will have notes and others won't. Right now if I try and do this (below) I get Cast from type DBNull to type String is not valid
VB Code:
Try
cnn.Open()
dr = cmd.ExecuteReader
While dr.Read()
tbRoNumb.Text = dr("RoNumber")
tbLastName.Text = dr("LastName")
tbFirstName.Text = dr("FirstName")
tbVehicle.Text = dr("Vehicle")
tbInsurer.Text = dr("Insurer")
tbColorCode.Text = dr("ColorCode")
tbAmount.Text = dr("Amount")
tbDateEntered.Text = dr("DateEntered")
tbDeliverDate.Text = dr("DeliveryDate")
tbDeliverTime.Text = dr("DeliveryTime")
tbPartsDate.Text = dr("PartsDate")
tbF.Text = dr("Frame")
tbM.Text = dr("Mech")
tbA.Text = dr("Align")
tbB.Text = dr("Body")
tbP.Text = dr("Paint")
tbReleaseDay.Text = dr("ReleaseDate")
tbReleaseTime.Text = dr("ReleaseTime")
CB1.Checked = dr("CB1")
CB2.Checked = dr("CB2")
CB3.Checked = dr("CB3")
CB4.Checked = dr("CB4")
CB5.Checked = dr("CB5")
tbMemo.Text = dr("Notes")
End While
cnn.Close()
How do I do this and still allow for nulls in one or more fields?