hello every one,

I am new in asp.net. I am tring to run update query with odbc data connection but it is not working

Dim CON As OdbcConnection
        Dim CONSTR As String = "Dsn=sdata"
        Dim DA As New OdbcDataAdapter
        Dim DT As New DataTable
        CON = New OdbcConnection(CONSTR)
        CON.Open()
        Dim strSQL As String
        strSQL = "select Status,class,username from user where     password='" & txtpw.Text & "' and userid='" & txtid.Text & "'"
        DA = New System.Data.Odbc.OdbcDataAdapter(strSQL, CON)
        DA.Fill(DT)
        If DT.Rows.Count = 1 Then
            Select Case DT.Rows(0)("status")
                Case "1"
                    MsgBox("User Already online..")
                Case "2"
                    strSQL = "UPDATE USER SET STATUS='1' WHERE  password='" & txtpw.Text & "' and userid='" & txtid.Text & "'"
                    DA = New System.Data.Odbc.OdbcDataAdapter(strSQL, CON)

                    Response.Redirect("MainPage.aspx")
                Case "3"
                    MsgBox("User On leave..")
                Case "4"
                    MsgBox("(User has left the job...")
            End Select
        Else
            MsgBox("Password might be wronge...", MsgBoxStyle.OkOnly, "Opps..There is problem..")
        End If
        CON.Close()

update tablename set user_name=parameter where user_id = parameter

hope it helps

Case "2"
strSQL = "UPDATE USER SET STATUS='1' WHERE password='" & txtpw.Text & "' and userid='" & txtid.Text & "'"
DA = New System.Data.Odbc.OdbcDataAdapter(strSQL, CON)

You have to use OdbcCommand.ExecuteNonQuery() to execute your UPDATE statement against your database.

See the below code

Case "2"
                    strSQL = "UPDATE USER SET STATUS='1' WHERE password='" & txtpw.Text & "' and userid='" & txtid.Text & "'"
                    Dim updCommand As New OdbcCommand(strSQL, CON)
                    updCommand.ExecuteNonQuery()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.