Hi, i've been trying to figure out how to update a row in my database, using a set of fields from the current form. The code which i have made so far is shown below, however it always comes up with an error message:
Please could you give me any pointers as to get it working? the connection to the database itself works, and this is the connection string:Code:Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click Dim SQL As String Dim updatelogin As New OleDbCommand Try Dim ObjectToedit As String ObjectToedit = txtusername.Text conn.Open() SQL = "UPDATE login.Username ('" = txtusername.Text & "' and set Password = '" & txtpassword.Text & "' and set title = '" & cbxtitle.SelectedIndex & "' and set Firstname = '" & txtfirstname.Text & "' and set Lastname = '" & txtsurname.Text & "' and set Age = '" & txtage.Text & "'WHERE ((username=" & ModifyUsers.lblselectedusername.Text & "')" updatelogin = New OleDbCommand(SQL, conn) updatelogin.ExecuteNonQuery() Catch ex As Exception MsgBox("Somthang broke Pa! : " & ex.ToString) End Try conn.Close() End sub
I'm hoping to update the row, based upon what is shown in the text box: ModifyUsers.lblselectedusername.TextCode:Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = cricket.mdb")
Thanks for any help![]()




Reply With Quote