0

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()
3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Ramesh S
0

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()
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.