Error: The value for column 'x' in table 'x' is DBNull....

G

Guest

Hello all,

This is probably a simple issue but since I am a newbie I am really stuck on
it. I have been developing some code and I was using rowPosition to pull data
from a Access Data base and I changed it to something that will read through
and match up my primary keys (MR#). Anyway this works fine as long as I have
data in every field in the table. But if/when it finds a field that is blank
(Null) I get this error “The value for column 'SurgType' in table
'Pat01Surgery' is DBNull.â€

This is the code I was using before….

'If dtSurgery.Rows(rowPositionSurg)("SurgType") Is DBNull.Value Then
' rdbtnInpatient.Checked = False
' rdbtnOutpatient.Checked = False
'ElseIf dtSurgery.Rows(rowPositionSurg)("SurgType") = "I"
Then
' rdbtnInpatient.Checked = True
'ElseIf dtSurgery.Rows(rowPositionSurg)("SurgType") = "O" Then
' rdbtnOutpatient.Checked = True
'End If


Now I am trying to use this code....

'If ShowSurg.SurgType Is DBNull.Value Then
'If IsDBNull(ShowSurg.SurgType) Then
If ShowSurg.SurgType Is String.Empty Then
rdbtnInpatient.Checked = False
rdbtnOutpatient.Checked = False
ElseIf ShowSurg.SurgType = "I" Then
rdbtnInpatient.Checked = True
ElseIf ShowSurg.SurgType = "O" Then
rdbtnOutpatient.Checked = True
End If

This code used to work fine before I had to change it. Now I can’t seem to
get the snytax right or something. As you can tell I have tried several
different ways to look for null. But it still kicks out that error.

Can anyone give me some advice on how this should be entered? I am still
learning so you may have to dummy it down for me. Thanks in advance for any
help you can give.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top