Hello,
I am writing a vb.net app.Using MySql db with the corelabs connector.
I am getting the following error when attempting to read values from a
datareader:
Cast from type 'DBNull' to type 'String' is not valid.
This error occurs on a field that DOES have data in it, but I can't
figure out why! Here is a sample of the code I am using:
strSql = ("Select * from pt_info where MRN='" & Form3.intNewMRN & "'")
myCmd = New MySqlCommand(st rSql, MyCon)
myReader = myCmd.ExecuteRe ader()
While myReader.Read()
txtFname.Text = myReader("fname ")
txtLname.Text = myReader("lname ")
txtMiddle.Text = myReader("middl e")
txtAddress.Text = myReader("addre ss")
txtAddress2.Tex t = myReader("addre ss2")
txtCity.Text = myReader("cityc ode")
txtZip.Text = myReader("zip") <--DBnull error here
.....more of the same
....
end while
Looking at the db, there data present in the zip field, but I cannot
seem to pull the info out.
Can anyone help with this problem????
TIA,
Daniel
I am writing a vb.net app.Using MySql db with the corelabs connector.
I am getting the following error when attempting to read values from a
datareader:
Cast from type 'DBNull' to type 'String' is not valid.
This error occurs on a field that DOES have data in it, but I can't
figure out why! Here is a sample of the code I am using:
strSql = ("Select * from pt_info where MRN='" & Form3.intNewMRN & "'")
myCmd = New MySqlCommand(st rSql, MyCon)
myReader = myCmd.ExecuteRe ader()
While myReader.Read()
txtFname.Text = myReader("fname ")
txtLname.Text = myReader("lname ")
txtMiddle.Text = myReader("middl e")
txtAddress.Text = myReader("addre ss")
txtAddress2.Tex t = myReader("addre ss2")
txtCity.Text = myReader("cityc ode")
txtZip.Text = myReader("zip") <--DBnull error here
.....more of the same
....
end while
Looking at the db, there data present in the zip field, but I cannot
seem to pull the info out.
Can anyone help with this problem????
TIA,
Daniel
Comment