Home All Groups Group Topic Archive Search About

Random 'Invalid Row Handle'

Author
3 Jan 2006 1:23 AM
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

Author
3 Jan 2006 3:20 AM
William (Bill) Vaughn
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...
  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
Author
3 Jan 2006 3:46 PM
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
Author
3 Jan 2006 7:26 PM
William (Bill) Vaughn
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
Author
4 Jan 2006 2:55 AM
Cyril Gupta
Hello Bill!

Thanks for that tip about updating using Transactions, it worked wonderfully. I also found out that this problem occurs with ADO too, but there's an easy worked using the Jet Access & Replication Objects (JRO).

Thanks for the help!

Cheers!

We all get by with a little help from friends. :)

AddThis Social Bookmark Button