lamp

A generic way to call ExecuteScalar

Published 05 February 10 07:16 AM | Frederick.Chapleau

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.

Filed under:

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Protected by FormShield
Refresh
Listen
Please enter the characters shown on the image


Code: