Olukayode Oluwole
asked on
How do i Handle a Case of DBNull so that I exit my application gracefully
I have the c# method stated below:
During Execution variable formexecutex can be "Y" , "N" OR may not even exist ie is DBNull
How do handle the DBNull case to use the else clause of the If Statement
See the error i got while trying
Thanks
Olukay
var reader = command.ExecuteReader();
if (reader.Read())
{
if ((string)reader?["formexecutex"] != null)
{
LoginDetails.staticformexecute = (string)reader["formexecutex"];
LoginDetails.staticaddbutton = (string)reader["addbuttonx"];
LoginDetails.staticupdatebutton = (string)reader["updatebuttonx"];
LoginDetails.staticdeletebutton = (string)reader["deletebuttonx"];
results.Add(model);
}
else
{
StandardMessages.FormPermission();
}
}
During Execution variable formexecutex can be "Y" , "N" OR may not even exist ie is DBNull
How do handle the DBNull case to use the else clause of the If Statement
See the error i got while trying
Thanks
Olukay
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Happy to help. Thanks for the points.
ASKER