1

Closed

Public methods throw when GetReader() returns null

description

Methods that use the protected member GetReader() must check whether the returned reader is null.

When GetReader encounters an exception, the error is caught and assigned to LastError and a null reference is returned. This causes GetDataTable, GetDataRow etc. to throw.

To reproduce, call GetDataRow with a text query but do not set IsTextQuery to true. This will cause GetReader to throw, catch and return null.
Closed May 31, 2012 at 3:44 AM by mafue

comments

mafue wrote May 24, 2012 at 3:01 AM

I've added null checks. Might want to revisit the design of this.

mafue wrote May 31, 2012 at 3:44 AM

With LastError now not swallowed by default, there is less chance of null being returned. Client code must either handle exceptions or handle null, depending on the options.