Code:
DataSet data = new DataSet();
SqlDataAdapter adap = new SqlDataAdapter( "SELECT * FROM MyTable WHERE ID BETWEEN 0 AND 500 ORDER BY ID", connection );
SqlCommandBuilder builder = new SqlCommandBuilder( adap );

adap.Fill( data, "MyTable" ); // ERROR (Exception)
There are 4 behaviors based on the amount of record I ask to fetch:

1) If the BETWEEN delta is <= 456 I get my records, no error.

2) If the delta is “not too big” like 457-500 I get the error:

An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll

Additional information: Index was outside the bounds of the array.

3) If the delta is “fairly big” like 1000 I get the error:

An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module.
Additional information: Object reference not set to an instance of an object.

If I click on “Break” I get the message “There is no source code available for the current location”. This is the only error that takes 2-5 minutes to occur, the others usually takes less than a second.

4) If the delta is “really big” (10000 and up) I get the error:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.



I am starting to believe there is an error in the C# ADO library with memory allocation or something!

Anyone have an idea of what is going on?

Thanks,

Chriss