473,326 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

FormatException & Data.SqlClient.SqlCommand

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 ***
Jan 8 '06 #1
2 1767
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" <no****@microsoft.com> wrote in message
news:up**************@TK2MSFTNGP09.phx.gbl...
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 ***

Jan 8 '06 #2
>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.
--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Jan 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mhnazly | last post by:
i'm trying to read data from SQL Server database using data reader and assigned it to a label in my asp.net web application. but when the button is clicked, nothing appears. please help, thanks. ...
2
by: sbox | last post by:
I've got an error "System.FormatException: Input string was not in a correct format." while I'm implementing a datagrid and a textbox What's wrong with it? Sub Button1_Click(sender As Object, e...
2
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET ...
5
by: DC Gringo | last post by:
I am having a problem reading a simple update to the database. Basically I'm testing a small change to the pubs database -- changing the price of the Busy Executive's Database Guide from 19.99 to...
0
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
1
by: weird0 | last post by:
localhost.BankingService bservice = new localhost.BankingService(); int balance=Convert.ToInt32(bservice.CheckBalance(InfoAccount.pincode)); // Line of Error How can i remove this error? I...
2
by: AB | last post by:
Hi to all, I have a problem about a importation of a file *.csv with SQL Server, through a bulk insert, called in a store procedure that a c# sw calls. This is the description of the error:...
5
nmm32
by: nmm32 | last post by:
I have a DataGrid which displays data with the aid of a procedure. I have tested the procedure inside the database and it is working fine. I have another procedure which adds another row to the...
0
by: cms3023 | last post by:
I have a DataGrid which displays data with the aid of a procedure. I have tested the procedure inside the database and it is working fine. The table inside the database has data that matches with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.