C
Cyril Gupta
Hello,
I am facing a weird problem using the DataReader.
This is what my code looks like.
---------------
Dim dbCommand As OleDbCommand
Dim dReader As OleDbDataReader
dbCommand = New OleDbCommand("SELECT * FROM CmpDet where cmpDet_CompanyID = " & CurrentCompany.CompanyID, DBCompany)
dReader = dbCommand.ExecuteReader 'Retrieve info from the database
dReader.Read() 'Read the record
'Load the company details
Try
CurrentCompany.Address = dReader.Item("cmpDet_MailAddress")
CurrentCompany.CompanyName = dReader.Item("cmpDet_CompanyName")
CurrentCompany.City = dReader.Item("cmpDet_CityName")
CurrentCompany.State = dReader.Item("cmpDet_State")
Catch ex As Exception
MsgBox(ex.Message)
Stop
End Try
'Empty the objects
dReader.Close()
dbCommand.Dispose()
dReader = Nothing
dbCommand = Nothing
---------------------
My problem is that on the dReader.item("cmpDet_MailAddress") line (When I try to read the contents of the dReader object). I sometimes get an error 'Invalid Row Handler'
This error does not occur all of the time, only some of it. Could it be because the records that the dReader retrieves were added to the db in a line just above this code block? I am using a dbCommand object with an "INSERT INTO" query to add the contents to the DB so I expect that there should be no problems retrieving data.
This error only occurs some of the time, and at other times it runs fine.
Any clues why this could be happening?
Thanks
Cyril Gupta
I am facing a weird problem using the DataReader.
This is what my code looks like.
---------------
Dim dbCommand As OleDbCommand
Dim dReader As OleDbDataReader
dbCommand = New OleDbCommand("SELECT * FROM CmpDet where cmpDet_CompanyID = " & CurrentCompany.CompanyID, DBCompany)
dReader = dbCommand.ExecuteReader 'Retrieve info from the database
dReader.Read() 'Read the record
'Load the company details
Try
CurrentCompany.Address = dReader.Item("cmpDet_MailAddress")
CurrentCompany.CompanyName = dReader.Item("cmpDet_CompanyName")
CurrentCompany.City = dReader.Item("cmpDet_CityName")
CurrentCompany.State = dReader.Item("cmpDet_State")
Catch ex As Exception
MsgBox(ex.Message)
Stop
End Try
'Empty the objects
dReader.Close()
dbCommand.Dispose()
dReader = Nothing
dbCommand = Nothing
---------------------
My problem is that on the dReader.item("cmpDet_MailAddress") line (When I try to read the contents of the dReader object). I sometimes get an error 'Invalid Row Handler'
This error does not occur all of the time, only some of it. Could it be because the records that the dReader retrieves were added to the db in a line just above this code block? I am using a dbCommand object with an "INSERT INTO" query to add the contents to the DB so I expect that there should be no problems retrieving data.
This error only occurs some of the time, and at other times it runs fine.
Any clues why this could be happening?
Thanks
Cyril Gupta