473,836 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Input string was not in correct format.

49 New Member
Hi. I need help. I am getting this error saying input string was not in a correct format. couldn't store <> in price column. expect type is decimal.

Here is my code below
Expand|Select|Wrap|Line Numbers
  1.  
  2.         Dim connectionString = "DRIVER=Client Access ODBC Driver (32-bit);UID=ODBC;PWD=xxxxxxxxxxxxxxxx;System=XXX.XXX.XXX.XXX"
  3.         Dim Order As Integer
  4.         Order = CInt(txtOrderNumber.Text)
  5.         Dim sql As String
  6.         Dim myconnection As OdbcConnection
  7.         Dim myCommand As OdbcDataAdapter
  8.         myconnection = New OdbcConnection(connectionString)
  9.         myCommand = New OdbcDataAdapter(sql, myconnection)
  10.         sql = "select  line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp  from rmsfiles2.obcop200 where ordno = " & Order.ToString()
  11.  
  12.         Dim newtable As New DataTable()
  13.         newtable.Columns.Add("Line#", GetType(Integer))
  14.         newtable.Columns.Add("Quano", GetType(Decimal))
  15.         newtable.Columns.Add("Actsp", GetType(Decimal))
  16.         newtable.Columns.Add("Prdno", GetType(Integer))
  17.  
  18.  
  19.         newtable.Columns("Line#").AutoIncrement = True
  20.         For i As Integer = 1 To 10
  21.             Dim newrow As DataRow = newtable.NewRow()
  22.             'newrow("Quano") = ""
  23.             newrow("ACTSP") = ""
  24.             newrow("Ordno") = ""
  25.             newtable.Rows.Add(newrow)
  26.         Next
  27.         gridview1.DataSource = newtable
  28.         gridview1.DataBind()
  29.  
Sep 18 '07 #1
13 8666
Plater
7,872 Recognized Expert Expert
Well for starters:
newrow("ACTSP") = ""
newrow("Ordno") = ""

ACTSPis defined as being a decimal, you're trying to add a string. Try using:
newrow("ACTSP") = 0.0

You never added a column called "Ordno" to your datatable, so that could be something.

You also don't appear to be doing anything with your database on that datatable? Did you leave that part of the code out?

Hi. I need help. I am getting this error saying input string was not in a correct format. couldn't store <> in price column. expect type is decimal.

Here is my code below
Expand|Select|Wrap|Line Numbers
  1.  
  2.         Dim connectionString = "DRIVER=Client Access ODBC Driver (32-bit);UID=ODBC;xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  3.         Dim Order As Integer
  4.         Order = CInt(txtOrderNumber.Text)
  5.         Dim sql As String
  6.         Dim myconnection As OdbcConnection
  7.         Dim myCommand As OdbcDataAdapter
  8.         myconnection = New OdbcConnection(connectionString)
  9.         myCommand = New OdbcDataAdapter(sql, myconnection)
  10.         sql = "select  line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp  from rmsfiles2.obcop200 where ordno = " & Order.ToString()
  11.  
  12.         Dim newtable As New DataTable()
  13.         newtable.Columns.Add("Line#", GetType(Integer))
  14.         newtable.Columns.Add("Quano", GetType(Decimal))
  15.         newtable.Columns.Add("Actsp", GetType(Decimal))
  16.         newtable.Columns.Add("Prdno", GetType(Integer))
  17.  
  18.  
  19.         newtable.Columns("Line#").AutoIncrement = True
  20.         For i As Integer = 1 To 10
  21.             Dim newrow As DataRow = newtable.NewRow()
  22.             'newrow("Quano") = ""
  23.             newrow("ACTSP") = ""
  24.             newrow("Ordno") = ""
  25.             newtable.Rows.Add(newrow)
  26.         Next
  27.         gridview1.DataSource = newtable
  28.         gridview1.DataBind()
  29.  
Sep 18 '07 #2
kjewell23
49 New Member
well, the ordno is a column field of my database in as400, Here is rest of my code
Expand|Select|Wrap|Line Numbers
  1. 'the button to submit
  2.  
  3.   Dim connectionString = "DRIVER=Client Access ODBC Driver (32-bit);UID=ODBC;PWD=xxxxxxxx;System=xxx.xxx.xxx.xxx"
  4.         Dim Order As Integer
  5.         Order = CInt(txtOrderNumber.Text)
  6.         Dim sql As String
  7.         Dim myconnection As OdbcConnection
  8.         Dim myCommand As OdbcDataAdapter
  9.         myconnection = New OdbcConnection(connectionString)
  10.         myCommand = New OdbcDataAdapter(sql, myconnection)
  11.         sql = "select  line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp  from rmsfiles2.obcop200 where ordno = " & Order.ToString()
  12.  
  13.         Dim newtable As New DataTable()
  14.         newtable.Columns.Add("Line#", GetType(Integer))
  15.         newtable.Columns.Add("Quano", GetType(Decimal))
  16.         newtable.Columns.Add("Actsp", GetType(Decimal))
  17.         newtable.Columns.Add("Prdno", GetType(Integer))
  18.  
  19.  
  20.         newtable.Columns("Line#").AutoIncrement = True
  21.         For i As Integer = 1 To 10
  22.             Dim newrow As DataRow = newtable.NewRow()
  23.             'newrow("Quano") = ""
  24.             newrow("ACTSP") = 0.0
  25.             newrow("Factory Number") = ""
  26.             newtable.Rows.Add(newrow)
  27.         Next
  28.         gridview1.DataSource = newtable
  29.         gridview1.DataBind()
  30.  
  31.     End Sub
  32.     Function GetData(ByVal myOrderNumber As Integer) As Data.DataView
  33.         Dim connectionString = "DRIVER=Client Access ODBC Driver (32-bit);UID=ODBC;PWD=xxxxxxxx;System=xxx.xxx.xxx.xxx"
  34.         Dim Order As Integer
  35.         Order = CInt(txtOrderNumber.Text)
  36.         Dim sql As String
  37.         Dim myconnection As OdbcConnection
  38.         Dim myCommand As OdbcDataAdapter
  39.         myconnection = New OdbcConnection(connectionString)
  40.         myCommand = New OdbcDataAdapter(sql, myconnection)
  41.         sql = "select  line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp  from rmsfiles2.obcop200 where ordno = " & Order.ToString()
  42.         Dim dr As Data.DataRow
  43.         Dim dt As New Data.DataTable 'the table that will hold the card holders
  44.  
  45.         dt.Columns.Add(New Data.DataColumn("Line #", GetType(Integer)))
  46.         dt.Columns.Add(New Data.DataColumn("Quantity", GetType(Decimal)))
  47.  
  48.         dr = dt.NewRow
  49.         dr("Line #") = "first row, line # "
  50.         dr("Quantity") = "first row, quantity"
  51.  
  52.         dt.Rows.Add(dr)
  53.  
  54.         dr = dt.NewRow
  55.         dr("Line #") = "second row, line # "
  56.         dr("Quantity") = "second row, quantity"
  57.  
  58.         dt.Rows.Add(dr)
  59.  
  60.         Dim dv As New Data.DataView(dt)
  61.         Return dv
  62.     End Function
  63.  
  64.  
Well for starters:
newrow("ACTSP") = ""
newrow("Ordno") = ""

ACTSPis defined as being a decimal, you're trying to add a string. Try using:
newrow("ACTSP") = 0.0

You never added a column called "Ordno" to your datatable, so that could be something.

You also don't appear to be doing anything with your database on that datatable? Did you leave that part of the code out?
Sep 18 '07 #3
Plater
7,872 Recognized Expert Expert
well, the ordno is a column field of my database in as400,
I had gathered that, but at no time do you appear to DO anything with your database. You set up a connection and set up a command, but never execute the command or populate your datatable from it.

Are you still getting errors though?
Sep 18 '07 #4
kjewell23
49 New Member
Ok . I thought I was, so how do I do that? I'm getting pass till the Ordno part so I change it to factory order and now it says that column factory number doesn't belong to the table. what does that mean? I know that its not recogniziting but it should. I think
I had gathered that, but at no time do you appear to DO anything with your database. You set up a connection and set up a command, but never execute the command or populate your datatable from it.

Are you still getting errors though?
Sep 18 '07 #5
Plater
7,872 Recognized Expert Expert
You want a DataTable(or DataSet) containing the values from your SQLCommand yes?

I moved things around because your order of operations was wrong
Expand|Select|Wrap|Line Numbers
  1. Dim connectionString = "DRIVER=Client Access ODBC Driver (32-bit);UID=ODBC;PWD=xxxxxxxx;System=xxx.xxx.xxx.xxx"
  2. Dim Order As Integer
  3. Dim sql As String
  4. Dim myconnection As OdbcConnection
  5. Dim myCommand As OdbcDataAdapter
  6.  
  7. Order = CInt(txtOrderNumber.Text)
  8. sql = "select line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp from rmsfiles2.obcop200 where ordno = " & Order.ToString()
  9. myconnection = New OdbcConnection(connectionString)
  10. myCommand = New OdbcDataAdapter(sql, myconnection)
  11.  
  12. Dim newtable As New DataTable()
  13.  
  14. myCommand.Fill(newtable)
  15.  
  16. gridview1.DataSource = newtable
  17. gridview1.DataBind()
  18.  
  19.  
This assumes that you have a valid table at "rmsfiles2.obco p200" with all the columns named as you specified.
Sep 18 '07 #6
kjewell23
49 New Member
It is a valid table. However I change the code just like you changes it in the submit button but it don't display anything. What could be wrong
You want a DataTable(or DataSet) containing the values from your SQLCommand yes?

I moved things around because your order of operations was wrong
Expand|Select|Wrap|Line Numbers
  1. Dim connectionString = "DRIVER=Client Access ODBC Driver (32-bit);UID=ODBC;PWD=xxxxxxxx;System=xxx.xxx.xxx.xxx"
  2. Dim Order As Integer
  3. Dim sql As String
  4. Dim myconnection As OdbcConnection
  5. Dim myCommand As OdbcDataAdapter
  6.  
  7. Order = CInt(txtOrderNumber.Text)
  8. sql = "select line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp from rmsfiles2.obcop200 where ordno = " & Order.ToString()
  9. myconnection = New OdbcConnection(connectionString)
  10. myCommand = New OdbcDataAdapter(sql, myconnection)
  11.  
  12. Dim newtable As New DataTable()
  13.  
  14. myCommand.Fill(newtable)
  15.  
  16. gridview1.DataSource = newtable
  17. gridview1.DataBind()
  18.  
  19.  
This assumes that you have a valid table at "rmsfiles2.obco p200" with all the columns named as you specified.
Sep 18 '07 #7
Plater
7,872 Recognized Expert Expert
It is a valid table. However I change the code just like you changes it in the submit button but it don't display anything. What could be wrong
That code should probably be in the form_load or somwhere where it will get executed in time to display on the webpage
Sep 18 '07 #8
kjewell23
49 New Member
The thing is that the customer won't type in a order number till the page load completes in a textbox then they hit submit then the data comes up
That code should probably be in the form_load or somwhere where it will get executed in time to display on the webpage
Sep 18 '07 #9
Plater
7,872 Recognized Expert Expert
Well you still need to have access to it at time of page_load

Check for the isPostBack variable to determine if the page is being reloaded to an event (like button clicking)
Then you can decide if the value is valid and get the dataset to populate the gridview
Sep 18 '07 #10

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

Similar topics

2
21156
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 execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: Input string was not in a correct format.
0
768
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 error and where it originated in the code. Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 457: <tr>
5
2519
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 not in the correct format. 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 error and where it...
1
1856
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
2860
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 = request.QueryString("enddate") Line 20: Line 21: if cint(eventid) = "0" then
0
2550
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 stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 237: Dim validNow As Integer = 1 Line...
0
12012
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the form controls so
0
3169
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 consists of a label control(hidden when run in browser). Also an Sql data source control connected to database tables for a photo album. Also label web control ID=UserIdValue. Also a Details View control ID=dvPictureInsert Problem is how to work out...
1
4529
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 Photoadmin/default.aspx i got the following message and info. 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...
1
4773
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 THE PROGRAM PLEASE HELP ME Server Error in '/WebApplication1' Application. -------------------------------------------------------------------------------- Input string was not in a correct format. Description: An unhandled exception occurred...
0
9813
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
10541
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10584
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
10248
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7782
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
6976
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
5645
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...
0
5817
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.