I can’t update more than one field in the records of an Access Database

This is the code I am using: myConnection.ConnectionString = connString myConnection.Open()

 Dim str As String = "Update TblManagers Set MgrName='Michael' Where ManagerID=1" Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection) Try cmd.ExecuteNonQuery() cmd.Dispose() myConnection.Close() Catch ex As Exception MsgBox(ex.Message) myConnection.Close() End Try 

And as soon as I add another column name and the value I want it gives says there’s a syntax error with the UPDATE statement.

Update:

Appearently it only let’s me edit the MgrName which is the second column. I tried to edit the position which is the third column and it gave me the Syntax error again: myConnection.ConnectionString = connString myConnection.Open()

 Dim str As String = "Update TblManagers Set Position='Michael' Where ManagerID=1" Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection) Try cmd.ExecuteNonQuery() cmd.Dispose() myConnection.Close() Catch ex As Exception MsgBox(ex.Message) myConnection.Close() End Try 

submitted by /u/EpicShaggy
[link] [comments]

Leave a Reply