locked
System.FormatException: Input string was not in a correct format. RRS feed

  • Question

  • User2016344432 posted
    can anyone help me solve this issue???
    How can i get this working???
    the CODVAL field in the database is of the TEXT type
    ----------------------------------------------------------------------------------------------------------------
    Exception Details:
    System.FormatException: Input string was not in a correct format.
    Line 40:         dbconn.close()
    ---------------------------------------------------------------------------------------------------------------------------------------------
        Private Sub btnValidar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnValidar.Click
            Dim dbcomm, dbconn, sql, username, codval
            username = Request.QueryString("user")
            dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("bd/fotodados.mdb"))
            sql = "Select codval from utilizadores where utilizador=@utilizador"
            With dbcomm.parameters
                .add(New OleDbParameter("@utilizador", username))
            End With
            dbcomm = (New OleDbCommand(sql, dbconn))
            dbcomm.connection.open()
            codval = dbcomm.executescalar()
            dbconn.close()

            Label1.Text = Request.QueryString("codval") & "-" & codval
            'Response.Redirect("criargal.aspx")
        End Sub

    Thursday, April 28, 2005 6:48 PM

All replies

  • User1640697700 posted

    Hi,

    you can try :

     Dim dbcomm, dbconn, sql, username, codval
            username = Request.QueryString("user")
            dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("bd/fotodados.mdb"))
            sql = "Select codval from utilizadores where utilizador= '" & username & "'"
            dbcomm = (New OleDbCommand(sql, dbconn))
            dbcomm.connection.open()
            codval = dbcomm.executescalar()
            dbconn.close()

            Label1.Text = Request.QueryString("codval") & "-" & codval
            'Response.Redirect("criargal.aspx")

             


    Regards

    Friday, May 27, 2005 4:00 PM