Public methods throw when GetReader() returns null


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 4:44 AM by mafue


mafue wrote May 24, 2012 at 4:01 AM

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

mafue wrote May 31, 2012 at 4: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.