FormatException & Data.SqlClient.SqlCommand

V

vooose

Consider executing a stored procedure which has a single INT arg:

SqlCommand command = new SqlCommand("Some_Stored_Procedure", conn);
command.CommandType =
CommandType.StoredProcedure; command.Parameters.Add("@UserID",
SqlDbType.Int); command.Parameters["@UserID"].Value = "150a";
command.ExecuteReader();

You receive the message "System.FormatException: Input string was not in
a correct format"

I would have expected something *slightly* more useful eg "For Parameter
'@UserID' the format '150a' is invalid".

Is this information hidden somewhere in the Exception object - or do I
have to print out each Parameter/Value of the SQLCommand and figure it
out myself?

Regards
 
A

Ali Raza Shaikh

I think Exceptions are used to give a General Error, instead of giving a
Specified Error (depends upon the Type of Exception u r using). Go down the
hieracrhy to the Format Exception Type, that can give you some useful
information

--
ALI RAZA SHAIKH
MCAD.net

alirazashaikh.blogspot.com
www.programmersparadise.cjb.net
 
V

vooose

Go down the hieracrhy to the Format Exception Type, that >can give you
some useful information

Such as? FormatException appears to have no extra information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top