473,706 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FormatException & Data.SqlClient. SqlCommand

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

SqlCommand command = new SqlCommand("Som e_Stored_Proced ure", conn);
command.Command Type =
CommandType.Sto redProcedure; command.Paramet ers.Add("@UserI D",
SqlDbType.Int); command.Paramet ers["@UserID"].Value = "150a";
command.Execute Reader();

You receive the message "System.FormatE xception: 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 1773
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.b logspot.com
www.programmersparadise.cjb.net
"vooose" <no****@microso ft.com> wrote in message
news:up******** ******@TK2MSFTN GP09.phx.gbl...
Consider executing a stored procedure which has a single INT arg:

SqlCommand command = new SqlCommand("Som e_Stored_Proced ure", conn);
command.Command Type =
CommandType.Sto redProcedure; command.Paramet ers.Add("@UserI D",
SqlDbType.Int); command.Paramet ers["@UserID"].Value = "150a";
command.Execute Reader();

You receive the message "System.FormatE xception: 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
1698
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. Private Sub btnTesting_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTesting.Click Dim cn As New SqlClient.SqlConnection Dim cm As New SqlClient.SqlCommand
2
11116
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 As EventArgs) DataGrid1.DataSource = MyQueryMethod(CInt(TextBox1.Text)) DataGrid1.DataBind() End Sub Function MyQueryMethod(ByVal others As String) As System.Data.DataSet
2
4586
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 Here's the scenario: 1. .NET Windows Client on a remote machine makes a web service call to update tables on a Web Server running SQL Server 2000. 2. The Update is updating about 1000 - 3000 records doing simple update statements like "Update...
5
1791
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 1997 and back. Unfortunately, it seems does reflect the change on my web form. Perhaps it's caching the data retrieved by the SQLDataAdapter? (All of my code is generated by VS.NET '03. FYI, it works fine when I test on my developer...
0
3003
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 not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Where Peter is the value entered in the textbox for firstname (fnameTBox) I'm sure the problem is something obvious but I...
1
2082
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 get the error above. Here are the definitions for the functions CheckBalance() and SearchDatabase().
2
4921
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: ----- System.Data.SqlClient.SqlException è stata individuata Message="Bulk Insert: Unexpected end-of-file (EOF) encountered in data file.\r\nOLE DB provider 'STREAM' reported an error. The provider did not give any information about the error.\r\nOLE...
5
2878
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 table, which is working fine inside the programming, and in the database. However, I still cannot figure out what am I doing wrong with the DataGrid configurations OR Database OR DataAdapter OR SqlSelectCommand ... I really don't know yet and I...
0
1769
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 the parameter. I have another procedure which adds another row to the table, which is working fine inside the programming, and in the database. However, I still cannot figure out what am I doing wrong with the DataGrid configurations OR...
0
8781
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9286
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9055
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7911
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5939
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4453
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2095
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.