How to handle Null Column values of SQLDataReader in C# ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

If you want to handle the Null column values of the sqldatareader object in C#, you can use the SqlReader.IsDBNull method to validate for it.

If the SqlReader.IsDBNull returns true then , the value is considered to be a null value and you can take the ction accordingly.

How to handle Null Column values of SQLDataReader in C# ?

if (!SqlReader.IsDBNull("EmailAddress"))
{
    emp.EmailAddress = sqlreader.GetString("EmailAddress");
}
%d bloggers like this: