Re: FormatException & Data.SqlClient.SqlCommand



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


"vooose" <nospam@xxxxxxxxxxxxx> wrote in message
news:upQtxKKFGHA.1288@xxxxxxxxxxxxxxxxxxxxxxx
> 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
>
>
>
> --
> Wal
> http://www.vooose.com
>
> *** Sent via Developersdex http://www.developersdex.com ***


.



Relevant Pages

  • Re: General Error - can I do better than that.
    ... I'm working in Windows with an odbc driver for accessing an Access db. ... Some INSERT statements throw exception with the "General Error" ...
    (comp.lang.java.databases)
  • General Error - can I do better than that.
    ... I'm working in Windows with an odbc driver for accessing an Access db. ... Some INSERT statements throw exception with the "General Error" ...
    (comp.lang.java.databases)
  • US vs UK datetime/string format failing on certain machines. Ideas
    ... I have a webform with a text box and a calendar control. ... or 6 lines of code just to format something from a text box ... String was not recognized as a valid DateTime. ... An unhandled exception occurred during the execution of the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Out of Memory Exception
    ... I catch the exception if it ... happens on the load and report an invalid file format.. ... > throws OutOfMemoryException if it does not recognize the image format. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Unterscheidung von FormatExceptions bei DateTime.ParseExact
    ... Exception feststellen. ... DateTime dtime; ... Grob gesagt habe ich so etwas: ... ParseDateTime(string date, string format) ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)