SqlDataReader IndexOutOfRangeException -- randomly

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

After upgrading my VB.NET Windows Forms project from VS 2003 to 2005,
I'm noticing random errors with DataReaders on certain users' PCs.
For example, I'll have the select statement:

"Select lRevision From TQuestionnaire Where lQuestionnaireID = " &
Me.QuestionnaireID

Which is passed to a DLL that returns a datareader, then I'll check
that the datareader has rows and that the column I selected is not
null:

If objDataReader.HasRows Then
If objDataReader.Read() Then
If Not IsDBNull(objDataReader("lRevision")) Then

But, for some users it is breaking on that last line with
System.IndexOutOfRangeException: lRevision
Apparently saying that the datareader does not have the one column I
selected, even though it had rows. Errors like this are happening in
various places, and the same user can click the Save button 10 times,
and it will save successfully five of the times, and five times break
at different places -- all the same kind of error. I've also noticed
that if a call tries to update a row with a certain ID or select a row
with a certain ID, sometimes it does not find the row, even though the
row with that ID is there all along. The code hasn't changed in years
and I never saw this problem when the project was in 2003. I read
similar problems in other posts, but unfortunately no resolution.
Please help if you can!

Thanks,
Kevin
 
Kevin,

Beside a miracle is the only thing I can think about that the programs are
made with option strict of and therefore use latebinding. If the needed
classes are not on the computer than is it not impossible that with late
binding and other class are taken than in past.

Just a gues

Cor
 
Kevin,

Beside a miracle is the only thing I can think about that the programs are
made with option strict of and therefore use latebinding. If the needed
classes are not on the computer than is it not impossible that with late
binding and other class are taken than in past.

Just a gues

Cor

Hi Cor,

Option Strict is on for all my classes, and I'm using early binding.
Thanks for the suggestion!

Kevin
 
Back
Top