For some school work I was given sourcecode in order to update data in an access database. However, when trying to use it I literally have no clue what the correct syntax is.
Here's the source code function to update it:
Sub UpdateData(ByVal dataToUpdate As String, ByVal updateCriteria As String)
'Assemble SQL query to update the specified record(s) with the specified value(s)
Dim sql As String = "UPDATE " & DBtable & " SET " & dataToUpdate & " WHERE " _
& updateCriteria
'Create an instance of data adapter (if not created already)
myDataAdapter = New OleDb.OleDbDataAdapter()
'Add command to update data (using data adaptor) based on SQL query above.
myDataAdapter.UpdateCommand = New OleDb.OleDbCommand(sql, myCon)
'Execute command to update data in the relevant database record(s)
myDataAdapter.UpdateCommand.ExecuteNonQuery()
MsgBox(sql)
End Sub
And this is what I'm trying to use to execute it, but I can't get the syntax right:
UpdateData("first_name = '" & Firstnamebox.Text & "' AND last_name = '" _
& Lastnamebox.Text & "' AND middle_name = '" & Middlenamebox.Text _
& "' AND age = '" & Agebox.Text & "' AND AdditionalInfo = '" & AddInfoBox.Text _
& "' AND User_level = '" & UserLevelBox.Text & "' AND username =' " _
& Usernamebox.Text & "' AND [password] = '" & Passwordbox.Text & "'",
"ID = '" & id & "'")
Any idea's on where i'm going wrong?
Thanks,