DataReader.Read not working? [Solved]
-
I am using the datareader to read through a foxpro table and when there are multiple records in the table it will only read the first one and then drop out of the loop. Any ideas on why it is doing this?
If DR.HasRows Then
While DR.Read()
random code here...
uploadDate = sql statement...
uplDate = New OleDb.OleDbCommand(uploadDate, objConnection)
DR = uplDate.ExecuteReader
DR.Read()
End While
End Ifmodified on Monday, April 12, 2010 3:10 PM
-
I am using the datareader to read through a foxpro table and when there are multiple records in the table it will only read the first one and then drop out of the loop. Any ideas on why it is doing this?
If DR.HasRows Then
While DR.Read()
random code here...
uploadDate = sql statement...
uplDate = New OleDb.OleDbCommand(uploadDate, objConnection)
DR = uplDate.ExecuteReader
DR.Read()
End While
End Ifmodified on Monday, April 12, 2010 3:10 PM
You're reusing the same reader to do something different which executes on the same connection. That's why it's dropping out of the loop. Change this to execute the second reader on a different connection if it's doing something with the data from the first query.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
I am using the datareader to read through a foxpro table and when there are multiple records in the table it will only read the first one and then drop out of the loop. Any ideas on why it is doing this?
If DR.HasRows Then
While DR.Read()
random code here...
uploadDate = sql statement...
uplDate = New OleDb.OleDbCommand(uploadDate, objConnection)
DR = uplDate.ExecuteReader
DR.Read()
End While
End Ifmodified on Monday, April 12, 2010 3:10 PM
It seems that you need to use two different Data Reader. DR is fine for the external while loop. But inside the while loop you are re-updating its value which is leading to the problem.. Try using another instance of the datareader, and it would work completely fine.