Execute Scalar and Null Values
Posted by: Wendy Armstrong
Date: November 21, 2004 02:16PM

Hi,

I am sure I have over looked something really important but does anyone know how to best catch a null value returned from calling ExecuteScalar on a MySqlCommand object?

I have a query which may or may not return a value. As I thought it should return an object reference with a database type of null, that I should test for it with DBNull. Doing so results in an invalid cast exception.

So...... I then thought I would cast it explicitly to a MySqlValueType but I get an error on this as well (again an invalid cast).

I can catch null values if I use :

myScalar !=null

Which suggests that I am not getting an object back with a Dbnull value. However, this will give me errors on values that are not null.

Has anyone had any luck with (or have a better understanding of) of execute scalar and null?

cheers
Wendy

Options: ReplyQuote


Subject
Written By
Posted
Execute Scalar and Null Values
November 21, 2004 02:16PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.