Simple question regarding null return objects

C

Chris

Hello:

I understand that the DataRow object offers .IsNull(), however once
the object has been retrieved from the row is it enough to just check
for DBNull or should I also check for null? As such:

// Begin C# ADO.NET Code

DataRow dr = GetDataRowFromSomeSource();
Object o = dr[ "existing_column" ];

if ( o is DBNull )
doNullAction();
else if ( o == null )
doNullAction();

// End C# ADO.NET Code

According to what I've read, only this should be necessary:

// Begin C# ADO.NET Code

DataRow dr = GetDataRowFromSomeSource();
Object o = dr[ "existing_column" ];

if ( o is DBNull )
doNullAction();
// No check for null here

// End C# ADO.NET Code

Correct?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top