Input string was not in correct format.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kjewell23
    New Member
    • Sep 2007
    • 49

    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
    [code=vbnet]

    Dim connectionStrin g = "DRIVER=Cli ent Access ODBC Driver (32-bit);UID=ODBC;P WD=xxxxxxxxxxxx xxxx;System=XXX .XXX.XXX.XXX"
    Dim Order As Integer
    Order = CInt(txtOrderNu mber.Text)
    Dim sql As String
    Dim myconnection As OdbcConnection
    Dim myCommand As OdbcDataAdapter
    myconnection = New OdbcConnection( connectionStrin g)
    myCommand = New OdbcDataAdapter (sql, myconnection)
    sql = "select line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp from rmsfiles2.obcop 200 where ordno = " & Order.ToString( )

    Dim newtable As New DataTable()
    newtable.Column s.Add("Line#", GetType(Integer ))
    newtable.Column s.Add("Quano", GetType(Decimal ))
    newtable.Column s.Add("Actsp", GetType(Decimal ))
    newtable.Column s.Add("Prdno", GetType(Integer ))


    newtable.Column s("Line#").Auto Increment = True
    For i As Integer = 1 To 10
    Dim newrow As DataRow = newtable.NewRow ()
    'newrow("Quano" ) = ""
    newrow("ACTSP") = ""
    newrow("Ordno") = ""
    newtable.Rows.A dd(newrow)
    Next
    gridview1.DataS ource = newtable
    gridview1.DataB ind()
    [/code]
    Last edited by Frinavale; Sep 19 '07, 04:20 PM. Reason: Fixed [code] tag, removed IP and Password to Database
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    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?

    Originally posted by kjewell23
    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
    [code=vbnet]

    Dim connectionStrin g = "DRIVER=Cli ent Access ODBC Driver (32-bit);UID=ODBC;x xxxxxxxxxxxxxxx xxxxxxxxxxxx"
    Dim Order As Integer
    Order = CInt(txtOrderNu mber.Text)
    Dim sql As String
    Dim myconnection As OdbcConnection
    Dim myCommand As OdbcDataAdapter
    myconnection = New OdbcConnection( connectionStrin g)
    myCommand = New OdbcDataAdapter (sql, myconnection)
    sql = "select line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp from rmsfiles2.obcop 200 where ordno = " & Order.ToString( )

    Dim newtable As New DataTable()
    newtable.Column s.Add("Line#", GetType(Integer ))
    newtable.Column s.Add("Quano", GetType(Decimal ))
    newtable.Column s.Add("Actsp", GetType(Decimal ))
    newtable.Column s.Add("Prdno", GetType(Integer ))


    newtable.Column s("Line#").Auto Increment = True
    For i As Integer = 1 To 10
    Dim newrow As DataRow = newtable.NewRow ()
    'newrow("Quano" ) = ""
    newrow("ACTSP") = ""
    newrow("Ordno") = ""
    newtable.Rows.A dd(newrow)
    Next
    gridview1.DataS ource = newtable
    gridview1.DataB ind()
    [/code]

    Comment

    • kjewell23
      New Member
      • Sep 2007
      • 49

      #3
      well, the ordno is a column field of my database in as400, Here is rest of my code
      [code=vbnet]
      'the button to submit

      Dim connectionStrin g = "DRIVER=Cli ent Access ODBC Driver (32-bit);UID=ODBC;P WD=xxxxxxxx;Sys tem=xxx.xxx.xxx .xxx"
      Dim Order As Integer
      Order = CInt(txtOrderNu mber.Text)
      Dim sql As String
      Dim myconnection As OdbcConnection
      Dim myCommand As OdbcDataAdapter
      myconnection = New OdbcConnection( connectionStrin g)
      myCommand = New OdbcDataAdapter (sql, myconnection)
      sql = "select line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp from rmsfiles2.obcop 200 where ordno = " & Order.ToString( )

      Dim newtable As New DataTable()
      newtable.Column s.Add("Line#", GetType(Integer ))
      newtable.Column s.Add("Quano", GetType(Decimal ))
      newtable.Column s.Add("Actsp", GetType(Decimal ))
      newtable.Column s.Add("Prdno", GetType(Integer ))


      newtable.Column s("Line#").Auto Increment = True
      For i As Integer = 1 To 10
      Dim newrow As DataRow = newtable.NewRow ()
      'newrow("Quano" ) = ""
      newrow("ACTSP") = 0.0
      newrow("Factory Number") = ""
      newtable.Rows.A dd(newrow)
      Next
      gridview1.DataS ource = newtable
      gridview1.DataB ind()

      End Sub
      Function GetData(ByVal myOrderNumber As Integer) As Data.DataView
      Dim connectionStrin g = "DRIVER=Cli ent Access ODBC Driver (32-bit);UID=ODBC;P WD=xxxxxxxx;Sys tem=xxx.xxx.xxx .xxx"
      Dim Order As Integer
      Order = CInt(txtOrderNu mber.Text)
      Dim sql As String
      Dim myconnection As OdbcConnection
      Dim myCommand As OdbcDataAdapter
      myconnection = New OdbcConnection( connectionStrin g)
      myCommand = New OdbcDataAdapter (sql, myconnection)
      sql = "select line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp from rmsfiles2.obcop 200 where ordno = " & Order.ToString( )
      Dim dr As Data.DataRow
      Dim dt As New Data.DataTable 'the table that will hold the card holders

      dt.Columns.Add( New Data.DataColumn ("Line #", GetType(Integer )))
      dt.Columns.Add( New Data.DataColumn ("Quantity", GetType(Decimal )))

      dr = dt.NewRow
      dr("Line #") = "first row, line # "
      dr("Quantity") = "first row, quantity"

      dt.Rows.Add(dr)

      dr = dt.NewRow
      dr("Line #") = "second row, line # "
      dr("Quantity") = "second row, quantity"

      dt.Rows.Add(dr)

      Dim dv As New Data.DataView(d t)
      Return dv
      End Function

      [/code]
      Originally posted by Plater
      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?
      Last edited by Frinavale; Sep 19 '07, 04:21 PM. Reason: Fixed [code] tag, removed IP and Password to Database

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Originally posted by kjewell23
        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?

        Comment

        • kjewell23
          New Member
          • Sep 2007
          • 49

          #5
          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
          Originally posted by Plater
          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?

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            You want a DataTable(or DataSet) containing the values from your SQLCommand yes?

            I moved things around because your order of operations was wrong
            [code=vbnet]
            Dim connectionStrin g = "DRIVER=Cli ent Access ODBC Driver (32-bit);UID=ODBC;P WD=xxxxxxxx;Sys tem=xxx.xxx.xxx .xxx"
            Dim Order As Integer
            Dim sql As String
            Dim myconnection As OdbcConnection
            Dim myCommand As OdbcDataAdapter

            Order = CInt(txtOrderNu mber.Text)
            sql = "select line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp from rmsfiles2.obcop 200 where ordno = " & Order.ToString( )
            myconnection = New OdbcConnection( connectionStrin g)
            myCommand = New OdbcDataAdapter (sql, myconnection)

            Dim newtable As New DataTable()

            myCommand.Fill( newtable)

            gridview1.DataS ource = newtable
            gridview1.DataB ind()

            [/code]

            This assumes that you have a valid table at "rmsfiles2.obco p200" with all the columns named as you specified.
            Last edited by Frinavale; Sep 19 '07, 04:22 PM. Reason: Removed IP and Password to Database

            Comment

            • kjewell23
              New Member
              • Sep 2007
              • 49

              #7
              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
              Originally posted by Plater
              You want a DataTable(or DataSet) containing the values from your SQLCommand yes?

              I moved things around because your order of operations was wrong
              [code=vbnet]
              Dim connectionStrin g = "DRIVER=Cli ent Access ODBC Driver (32-bit);UID=ODBC;P WD=xxxxxxxx;Sys tem=xxx.xxx.xxx .xxx"
              Dim Order As Integer
              Dim sql As String
              Dim myconnection As OdbcConnection
              Dim myCommand As OdbcDataAdapter

              Order = CInt(txtOrderNu mber.Text)
              sql = "select line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp from rmsfiles2.obcop 200 where ordno = " & Order.ToString( )
              myconnection = New OdbcConnection( connectionStrin g)
              myCommand = New OdbcDataAdapter (sql, myconnection)

              Dim newtable As New DataTable()

              myCommand.Fill( newtable)

              gridview1.DataS ource = newtable
              gridview1.DataB ind()

              [/code]

              This assumes that you have a valid table at "rmsfiles2.obco p200" with all the columns named as you specified.
              Last edited by Frinavale; Sep 19 '07, 04:22 PM. Reason: Removed IP and Password to Database

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                Originally posted by kjewell23
                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

                Comment

                • kjewell23
                  New Member
                  • Sep 2007
                  • 49

                  #9
                  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
                  Originally posted by Plater
                  That code should probably be in the form_load or somwhere where it will get executed in time to display on the webpage

                  Comment

                  • Plater
                    Recognized Expert Expert
                    • Apr 2007
                    • 7872

                    #10
                    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

                    Comment

                    • Dharmaraju
                      New Member
                      • Sep 2007
                      • 13

                      #11
                      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.

                      Comment

                      • kjewell23
                        New Member
                        • Sep 2007
                        • 49

                        #12
                        How do I do that. I look and I kinda understand but not for sure how to do the code
                        Originally posted by Plater
                        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

                        Comment

                        • NeoPa
                          Recognized Expert Moderator MVP
                          • Oct 2006
                          • 32634

                          #13
                          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.

                          Comment

                          • Dharmaraju
                            New Member
                            • Sep 2007
                            • 13

                            #14
                            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

                            Comment

                            Working...