View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 07:16 PM
Guinness Mann
 
Posts: n/a
Default Re: <undefined value>

In article <pV4hb.9598$mQ2.8310@newsread1.news.atl.earthlink. net>,
danguzman@nospam-earthlink.net says...
> > How do I do test for that condition?

>
> Object myScalarResult = myCommand.ExecuteScalar();
> if ( myScalarResult == null )
> {
> // no result returned
> }


Sheesh. Simple enough once you know the answer, eh? Thanks!

Here's what I've been doing:

Object myScalarResult = myCommand.ExecuteScalar();
int returnValue = Convert.ToInt32(myScalarResult);

Which returns 0 if null, otherwise the Int32 I'm looking for.
Fortuitously, 0 is not in the possible solution set, so by coincidence,
it works.

Thanks again,

-- Rick

Reply With Quote