|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Random 'Invalid Row Handle'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 would suspect your data provider. It's either JET or some other OLE DB data source which are notorious for lazy writes.
-- ____________________________________ William (Bill) Vaughn Author, Mentor, Consultant Microsoft MVP INETA Speaker www.betav.com/blog/billva www.betav.com Please reply only to the newsgroup so that others can benefit. This posting is provided "AS IS" with no warranties, and confers no rights. __________________________________ "Cyril Gupta" <nom***@mail.com> wrote in message news:Obr0$RAEGHA.3892@TK2MSFTNGP10.phx.gbl... I am facing a weird problem using the DataReader.Hello, 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 Hello Bill,
I think you've got a breakthrough right there. Yep my data provider is Jet. Any ideas on how I can make sure the data is updated before I do the retrieval operation? Thanks for that keyword 'lazy write' I will try to do google on it and see if any one else has had the problem. Thanks Cyril There are a couple of ways, but the easiest is to perform updates in a transaction.
-- ____________________________________ William (Bill) Vaughn Author, Mentor, Consultant Microsoft MVP INETA Speaker www.betav.com/blog/billva www.betav.com Please reply only to the newsgroup so that others can benefit. This posting is provided "AS IS" with no warranties, and confers no rights. __________________________________ "Cyril Gupta" <nom***@mail.com> wrote in message news:OJ3aYzHEGHA.3920@tk2msftngp13.phx.gbl... Hello Bill,I think you've got a breakthrough right there. Yep my data provider is Jet. Any ideas on how I can make sure the data is updated before I do the retrieval operation? Thanks for that keyword 'lazy write' I will try to do google on it and see if any one else has had the problem. Thanks Cyril |
|||||||||||||||||||||||