I'm currently working on a simple project the shows a list of people, and basically indicates if they are in the office, or out. The people can also edit the list to indicate whether they are in the office or out, and update a message saying when they'll be back.
My problem is that when I update the list, I'm getting an error that says that there is a Syntax error in my Update Statement, but I can not find it. I am using visual studio 2012, developing in VB.NET, and using an access database, accessed through an OleDB connection.
Here is the VB code in question
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If InOutComboBox.SelectedItem = "IN" Then
MessageTextBox.Text = ""
End If
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\People.mdb")
con.Open()
If ListView1.SelectedIndices.Count > 0 Then
Dim comStr As String = "UPDATE tblStaffNames SET OutIn = '" & InOutComboBox.SelectedItem & "', Note = '" & MessageTextBox.Text & "' WHERE recid = " & ListView1.SelectedItems(0).SubItems(0).Text
cmd = New OleDbCommand(comStr, con)
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message & " - " & ex.Source)
End Try
End If
ListView1.Clear()
LoadList()
End Sub
And here is a sample value of comStr when I run the code
UPDATE tblStaffNames SET OutIn = 'OUT', Note = 'on vacation' WHERE recid = 26
Any help would be much appreciated. Thank You.