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.
 
Back
Top