Test for DBNull

  • Thread starter Thread starter MFRASER
  • Start date Start date
M

MFRASER

How do I test for DBNull? The following does not work.
System.Data.DataRow aRow;
if (aRow["ServerName"] != null)

{

aServer = (string)aRow["ServerName"];

}
 
MFRASER,

You can check against the static value property of DBNull, like so:

if (aRow["ServerName"] != DBNull.Value)

Hope this helps.
 

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

Back
Top