locked
Update query problem plz help RRS feed

  • Question

  • User1331319426 posted

    I am using this code:

    Protected Sub Updatebtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Updatebtn.Click
            Dim dbconn As OleDbConnection
            Dim dbcomm As OleDbCommand
            dbconn = New OleDbConnection(ConfigurationManager.ConnectionStrings("dataconnection").ConnectionString)
            dbconn.Open()
            dbcomm = New OleDbCommand("Update bltable SET Mobno ='" & MobTextBox.Text & "' where Username ='" & Session("Admin").ToString & "'", dbconn)
            dbcomm.ExecuteNonQuery()
        End Sub

    Protected Sub Updatebtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Updatebtn.Click

            Dim dbconn As OleDbConnection


            Dim dbcomm As OleDbCommand



            dbconn = New OleDbConnection(ConfigurationManager.ConnectionStrings("dataconnection").ConnectionString)

            dbconn.Open()

            dbcomm = New OleDbCommand("Update bltable SET Mobno ='" & MobTextBox.Text & "' where Username ='" & Session("Admin") & "'", dbconn)

            dbcomm.ExecuteNonQuery()

        End Sub


    Please tell me what is the error. It is not working at all. Records are not getting updated.

    Tuesday, December 7, 2010 12:42 AM

Answers

  • User-1675817941 posted

    hi,

    Update bltable SET Mobno ='" & MobTextBox.Text & "' where Username ='" & Session("Admin") & "'", dbconn 

    i think  the underlined code is wrong. take session value into one variable and try.

    Thanks,

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 7, 2010 9:24 AM

All replies

  • User384031199 posted

    Hi,

    Are you getting any exception? Can you enclose your code that opens the connection and executes the query inside a try...catch block?

     

    Tuesday, December 7, 2010 1:01 AM
  • User-1675817941 posted

    hi,

    Update bltable SET Mobno ='" & MobTextBox.Text & "' where Username ='" & Session("Admin") & "'", dbconn 

    i think  the underlined code is wrong. take session value into one variable and try.

    Thanks,

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 7, 2010 9:24 AM