This is a multi-part message in MIME format.
------=_NextPart_000_0203_01C61032.6F29FDF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
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 =3D New OleDbCommand("SELECT * FROM CmpDet where =
cmpDet_CompanyID =3D " & CurrentCompany.CompanyID, DBCompany)
dReader =3D dbCommand.ExecuteReader 'Retrieve info from the database
dReader.Read() 'Read the record
'Load the company details
Try
CurrentCompany.Address =3D dReader.Item("cmpDet_MailAddress")
CurrentCompany.CompanyName =3D dReader.Item("cmpDet_CompanyName")
CurrentCompany.City =3D dReader.Item("cmpDet_CityName")
CurrentCompany.State =3D dReader.Item("cmpDet_State")
Catch ex As Exception
MsgBox(ex.Message)
Stop
End Try
'Empty the objects
dReader.Close()
dbCommand.Dispose()
dReader =3D Nothing
dbCommand =3D 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'=20
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
------=_NextPart_000_0203_01C61032.6F29FDF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DVerdana size=3D2>Hello,</FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2></FONT> </DIV>
<DIV><FONT face=3DVerdana size=3D2>I am facing a weird problem using the =
DataReader.</FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2></FONT> </DIV>
<DIV><FONT face=3DVerdana size=3D2>This is what my code looks =
like.</FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2></FONT> </DIV>
<DIV><FONT face=3DVerdana size=3D2>---------------<BR></FONT><FONT =
face=3DVerdana=20
size=3D2>Dim dbCommand As OleDbCommand<BR>Dim dReader As=20
OleDbDataReader</FONT></DIV>
<DIV>
<P><FONT face=3DVerdana size=3D2>dbCommand =3D New OleDbCommand("SELECT =
* FROM CmpDet=20
where cmpDet_CompanyID =3D " & CurrentCompany.CompanyID, =
DBCompany)<BR>dReader=20
=3D dbCommand.ExecuteReader 'Retrieve info from the =
database<BR>dReader.Read()=20
'Read the record</FONT></P>
<P><FONT face=3DVerdana size=3D2>'Load the company=20
details<BR>Try<BR> CurrentCompany.Address =3D=20
dReader.Item("cmpDet_MailAddress")<BR> CurrentCompany.CompanyName =
=3D=20
dReader.Item("cmpDet_CompanyName")<BR> CurrentCompany.City =3D=20
dReader.Item("cmpDet_CityName")<BR> CurrentCompany.State =3D=20
dReader.Item("cmpDet_State")<BR>Catch ex As=20
Exception<BR> MsgBox(ex.Message)<BR> Stop<BR>End =
Try</FONT></P>
<P><FONT face=3DVerdana size=3D2>'Empty the objects</FONT></P>
<P><FONT face=3DVerdana =
size=3D2>dReader.Close()<BR>dbCommand.Dispose()<BR>dReader =3D=20
Nothing<BR>dbCommand =3D Nothing</FONT></P>
<P><FONT size=3D2><FONT =
face=3DVerdana>---------------------</FONT></FONT></P>
<P><FONT face=3DVerdana size=3D2>My problem is that on the=20
dReader.item("cmpDet_MailAddress") line (When I try to read the contents =
of the=20
dReader object). I sometimes get an error 'Invalid Row Handler' =
</FONT></P>
<P><FONT face=3DVerdana size=3D2>This error does not occur all of the =
time, only=20
some of it. Could it be because the records that the dReader retrieves =
were=20
added to the db in a line just above this code block? I am using a =
dbCommand=20
object with an "INSERT INTO" query to add the contents to the DB so I =
expect=20
that there should be no problems retrieving data.</FONT></P>
<P><FONT face=3DVerdana size=3D2>This error only occurs some of the =
time, and at=20
other times it runs fine.</FONT></P>
<P><FONT face=3DVerdana size=3D2>Any clues why this could be =
happening?</FONT></P>
<P><FONT face=3DVerdana size=3D2>Thanks<BR>Cyril=20
Gupta</FONT></P></DIV></BODY></HTML>
------=_NextPart_000_0203_01C61032.6F29FDF0--