Reputation: 1
When I select rows from DataGridView the data will show up on Textbox. But by the time I click Delete Button this shows up
Error message:
Syntax error (missing operator) in query expression 'First Name='Jesus Anthony''.
It appears that there's a missing operator. What does it mean? My TextBox is not empty. Here is the code I used
provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
datafile = "C:\Users\Anthony\Desktop\Registration Form\Database\EmployeeRegistration.accdb"
connString = provider & datafile
myConnection.ConnectionString = connString
myConnection.Open()
Dim str As String
str = "DELETE FROM tblemployees WHERE First Name='" & Form1.firstname.Text & "'"
cmd = New OleDb.OleDbCommand(str, myConnection)
Try
cmd.ExecuteNonQuery()
cmd.Dispose()
myConnection.Close()
clearall()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Upvotes: 0
Views: 333
Reputation: 180908
First Name
has a space in it. If that's really the field name, you have to surround it with brackets, like this:
[First Name]
Otherwise, it's just FirstName
Upvotes: 2