Monday, March 12, 2012

How to handle null value

I got trouble with System.Null.ReferenceException. Please guide me how to manipulate it.

Below is my error code line, when the result of my query returns null value.

string FATypeName = SelectCommand.ExecuteScalar().ToString().Trim();

Thanks,


string FATypeName = SelectCommand.ExecuteScalar()
if ( FATypeName!=null )
{
FATypeName=FATypeName.ToString().Trim();
}
else
{
FATypeName=String.Empty;
}

Labels: , , , , , , , , , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home