473,407 Members | 2,676 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,407 software developers and data experts.

Input string was not in correct format.

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 8642
Plater
7,872 Expert 4TB
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
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 Expert 4TB
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
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 Expert 4TB
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.obcop200" with all the columns named as you specified.
Sep 18 '07 #6
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.obcop200" with all the columns named as you specified.
Sep 18 '07 #7
Plater
7,872 Expert 4TB
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
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 Expert 4TB
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
Don't specify the column type when you adding the column to the datatable .the Column automatically take the datatype when you update the column.
Sep 19 '07 #11
How do I do that. I look and I kinda understand but not for sure how to do the code
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 19 '07 #12
NeoPa
32,556 Expert Mod 16PB
kjewell23,

Please review the posts you've made in this thread already and notice that Frinavale has had to edit many of them for you to protect the privacy of your firm.
Posting IP address and password on a public web site is a very dangerous thing to do (I assume it was a publicly available IP address) and could cause your company to lose a great deal that is valuable (possibly money but certainly information).
In my experience, if you were found out posting that information on a public web site, you would lose your job. This is quite a serious matter.
I notice that you don't seem to have heeded Frinavale's warning to you on this very issue in a previous thread (Data in dataset but not displaying in gridview).

Please treat this as a friendly, though probably last, warning on the matter.

MODERATOR.
Sep 19 '07 #13
Please don't mention the type of the column
dt.Columns.Add(New Data.DataColumn("Line #", GetType(Integer)))

You should mention like this
dt.Columns.Add(New Data.DataColumn("Quantity"))


then it will accep the value .Please do
Sep 20 '07 #14

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...
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: 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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.