F
fniles
I am accessing MS Access db with tblA whose column UNABLE can have NULL
value. When I access UNABLE whose value is null, I got an error "
Run-time exception thrown : System.InvalidCastException - Specified cast is
not valid." either when I do
IsDBNull(dr.GetString(0))
or
dr.GetString(0)
How can I fix this problem ?
Thanks.
Dim sUnable as string
Dim sql As String
Dim dr As OleDb.OleDbDataReader
Dim cmd As New OleDb.OleDbCommand
sql = "select UNABLE from tblA where ACCOUNT = 'xyz'"
With cmd
.Connection = g_ConnectionDemoOLE
.CommandText = sql
dr = .ExecuteReader()
End With
Do While dr.Read
If bErr Then
sUnable = ""
Else
If IsDBNull(dr.GetString(0)) Then sUnable = "" Else sUnable =
dr.GetString(0) --> ERROR HERE
End If
If bErr Then sUnable = ""
Loop
value. When I access UNABLE whose value is null, I got an error "
Run-time exception thrown : System.InvalidCastException - Specified cast is
not valid." either when I do
IsDBNull(dr.GetString(0))
or
dr.GetString(0)
How can I fix this problem ?
Thanks.
Dim sUnable as string
Dim sql As String
Dim dr As OleDb.OleDbDataReader
Dim cmd As New OleDb.OleDbCommand
sql = "select UNABLE from tblA where ACCOUNT = 'xyz'"
With cmd
.Connection = g_ConnectionDemoOLE
.CommandText = sql
dr = .ExecuteReader()
End With
Do While dr.Read
If bErr Then
sUnable = ""
Else
If IsDBNull(dr.GetString(0)) Then sUnable = "" Else sUnable =
dr.GetString(0) --> ERROR HERE
End If
If bErr Then sUnable = ""
Loop