No data exists for the row/column error

jdy0803

Well-known member
Joined
Sep 9, 2012
Messages
73
Location
Santa Clarita
Programming Experience
10+
No data exists for the row/column error occurs from my following VB.NET code but can't find any problem.
I checked the database and correct data exists in the record.


Dim mycmd As OleDbCommand
Dim dr As OleDbDataReader
mycmd = New OleDbCommand()
mycmd.Connection = cn
mycmd.CommandText = "Select * FROM cdm WHERE seq_no=" & CStr(nProductNo)
dr = mycmd.ExecuteReader()
szRet = ""
If dr.HasRows Then
If Not IsDBNull(dr("notes")) Then
szRet = dr("notes").ToString.Trim
End If
End If
dr.Close()
mycmd.Dispose()



Can anybody help me?
 
From the documentation:
The default position of the OleDbDataReader is before the first record. Therefore, you must call Read to start accessing any data.
 
Back
Top