odbcdatareader vs sqldatareader

  • Thread starter Thread starter cj2
  • Start date Start date
C

cj2

I just found out that using the odbcdatareader I can executereader then
immediately start using the data like myodbcreader("field") without
using myodbcreader.read first. With the sqldatareader this does not
work. I have to do mysqlreader.read before I can use the data. I'm
curious why the difference.
 
I just found out that using the odbcdatareader I can executereader then
immediately start using the data like myodbcreader("field") without
using myodbcreader.read first. With the sqldatareader this does not
work. I have to do mysqlreader.read before I can use the data. I'm
curious why the difference.

Why? Because the implementers of the OdbcDataReader decided to check to see
if the value had been read or not, and if not fetch :)
 
cj2 said:
I just found out that using the odbcdatareader I can executereader then
immediately start using the data like myodbcreader("field") without
using myodbcreader.read first. With the sqldatareader this does not
work. I have to do mysqlreader.read before I can use the data. I'm
curious why the difference.

Then that would be an error in the implementation of the OdbcDataReader.
The documentation clearly says:

"The default position of the OdbcDataReader is before the first record.
Therefore, you must call Read to start accessing any data."

Are you sure that you don't call Read before using the data?
 
Then that would be an error in the implementation of the OdbcDataReader.
The documentation clearly says:

"The default position of the OdbcDataReader is before the first record.
Therefore, you must call Read to start accessing any data."

Are you sure that you don't call Read before using the data?

I looked at the implementation in Reflector, and the OdbcDataReader will
automatically fetch data if it has not already done so....

The documentation is definately out of sync with the implementation... And I
think this implementation is out of sync with pretty much every other provider
I've used :)
 
Back
Top