Testing for null values in reader.GetDouble(x);

Jul 2, 2007 at 11:38 PM
Our database can have nulls in some fields, when connecting using Enterprise Lib, and executing a reader we get a null value exception. Here is some code.

myObject.myVal = reader.GetDouble( someIndex );

If the value at someIndex is NULL, I get an exception throw. So, how does one go about catching a null? I tried the following and it does not seem to help.

if( reader.GetDouble( someIndex ) == System.DBNull )
do something

But, then I get a complie error System.DBNull is a type, which is not valid in the given context. Sounds reasonable... But, what are other options here to test if a value is null before I try accessing it?

Jul 3, 2007 at 3:38 AM
This forum is for CodePlex web site issues and discussion only. Please re-post your question in the appropriate project's forums.