Skip to content Skip to sidebar Skip to footer

Sqldatareader Does Not Return All Records

I am experiencing a problem with ADO.NET SqlDataReader. When I run underlying stored procedure directly in SSMS - it returns 1.7 million of records. When I run a related VB.NET cod

Solution 1:

Thanks to reference pointed by @Tim Schemlter I found the option "CommandBehavior.SequentialAccess" for DataReader creation. That fixed the issue. E.g. instead of

drReader = oCommand.ExecuteReader();

use

drReader = oCommand.ExecuteReader(CommandBehavior.SequentialAccess);

and it works correctly.

Solution 2:

Have you tried using the GetInt64() method instead? I realize that with only 1.7 million records, the GetInt32() method should be large enough; I was more just curious.

Also, if you think that SQL cannot keep up with the DataReader, have you tried adding a wait in the loop to allow it to catch up?

Post a Comment for "Sqldatareader Does Not Return All Records"