473,378 Members | 1,478 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,378 software developers and data experts.

Input string was not in a correct format.

When i write the following lines then i get an error like..
Input string was not in a correct format.
Expand|Select|Wrap|Line Numbers
  1.  cmd = new SqlCommand("select Username, Address, City, State, Zip " + "HomePhone, Extension, MobilePhone from Employees" + "where EmployeeID=@EmployeeID", conn);
  2.  
  3.  cmd.Parameters.Add("@EmployeeID",SqlDbType.Int);
  4.  cmd.Parameters["@EmployeeID"].Value =Convert.ToInt32( DropDownList1.SelectedItem.Value);
  5.         try
  6.         {
  7.             conn.Open();
  8.             reader = cmd.ExecuteReader();
  9.             {
  10.  
  11.                 {
  12.      nametextbox.Text = reader["Name"].ToString();
  13.      usernameTextBox.Text = reader["Username"].ToString();
  14.      addressTextBox.Text = reader["Address"].ToString();
  15.      cityTextBox.Text = reader["City"].ToString();
  16.       stateTextBox.Text = reader["State"].ToString();
  17.       zipTextBox.Text = reader["Zip"].ToString();
  18.       homephoneTextBox.Text = reader["HomePhone"].ToString();
  19.       extentionTextBox.Text = reader["Extension"].ToString();
  20.       mobileTextBox.Text = reader["MobilePhone"].ToString();
  21.                 }
  22.             }
  23.             reader.Close();
  24.             updateButton.Enabled = true;
  25.         }
  26.        /* catch
  27.         {
  28.             Label1.Text = "Error!!!!!!";
  29.         }*/
  30.         finally
  31.         {
  32.  
  33.             conn.Close();
  34.         }
  35.     }
  36. }
Oct 26 '10 #1
1 4105
NitinSawant
270 100+
There is no comma between zip and homephone

Try this:
Expand|Select|Wrap|Line Numbers
  1. cmd = new SqlCommand("select Username, Address, City, State, Zip, HomePhone, Extension, MobilePhone from Employees where EmployeeID=@EmployeeID", conn);
Also, have you tried debugging by adding breakpoint on
line 4
Expand|Select|Wrap|Line Numbers
  1. MessageBox.Show(DropDownList1.SelectedItem.Value+"");//add this
Oct 27 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jim | last post by:
im using asp.net, C# to enter data into a table in sql server...however im getting this error: Input string was not in a correct format. Description: An unhandled exception occurred during the...
0
by: lianfe_ravago | last post by:
Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the...
1
by: Big E | last post by:
Here is my code below. I recieve this error when I run MyCommand.SelectCommand.ExecuteNonQuery() Thanks. Big E Sub MyDataGrid_Update(ByVal Sender As Object, ByVal E As...
5
by: blackg | last post by:
Input string not in correct format -------------------------------------------------------------------------------- I am trying to view a picture from a table. I am getting this error Input string...
1
by: amitbadgi | last post by:
Welcome back amitbadgi | Logout | Faq Knowledge Discovery Keys COMPUTER PROGRAMMING, DATA MINING, STATISTICS, ARTIFICIAL INTELLIGENCE * Settings * Photos * Lists * MVPs * Forums * Blogs
1
by: amitbadgi | last post by:
I am gettign this error, while migration an app to asp.net Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 19: Dim enddate =...
0
by: hudhuhandhu | last post by:
have got an error which says Input string was not in a correct format. as follows.. Description: An unhandled exception occurred during the execution of the current web request. Please review the...
0
by: sehguh | last post by:
Hiya Folks, I am Currently using windows xp. Also using Visual Web Developer 2005 and Microsoft Sql server 2005. The main page consists of an aspx page and a master page. The page also...
1
by: sehguh | last post by:
Hello folks I have recently been studying a book called "sams teach yourself asp.net 2.0 in24 hours by scott mitchell. I have reached page 614 but when i tried to run an asp page called...
1
by: differentsri | last post by:
THIS IS AN ASP.NET 1.1 APPLICATION IAM TRYING TO UPDATE THE FIELD BUT I AM NOT ABLE TO UPDATE IT? CAN U TELL THE REASON ? IT IS GIVING THE FOLLOWING ERROR BELOW I HAVE ALSO GIVEN THE CODE OF...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.