A generic way to call ExecuteScalar
When calling execute Scalar, we always begin by calling it with some code like
int i = cmd.ExecuteScalar();
What’s wrong with this picture?… what if, the first field of the first row is… NULL?
so…
int i;
object o = cmd.ExecuteScalar();
if(o != null)
i = (int)o;
-f.