G
Guest
Hi -
I need to detect when the ExecuteScalar() method of the cmd object returns
NULL. I have tried the below code, however, it always returns false (this is
to say, that ExecuteScalar never returns NULL when in fact it does):
cmd.CommandText = "...SQL String goes here...";
cmd.CommandType = CommandType.Text;
if (cmd.ExecuteScalar() == System.DBNull.Value)
iScorecardId = 1;
else
iScorecardId = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
Is there another way to check if ExecuteScalar returns NULL?
Thanks,
I need to detect when the ExecuteScalar() method of the cmd object returns
NULL. I have tried the below code, however, it always returns false (this is
to say, that ExecuteScalar never returns NULL when in fact it does):
cmd.CommandText = "...SQL String goes here...";
cmd.CommandType = CommandType.Text;
if (cmd.ExecuteScalar() == System.DBNull.Value)
iScorecardId = 1;
else
iScorecardId = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
Is there another way to check if ExecuteScalar returns NULL?
Thanks,