My program works perfectly, but now the only problem is that the when the database has been updated, an alert box will appear saying:
Syntax error (missing operator) in query expression 'ID='.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim choice As String
choice = MsgBox("Do you really want to delete?", MsgBoxStyle.YesNo)
If choice = vbYes Then
cnn = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database.accdb")
Dim str As String = ("DELETE FROM TableName WHERE ID= " & ComboBox1.Text & "")
command = New OleDb.OleDbCommand(str, cnn)
da = New OleDb.OleDbDataAdapter(command)
cnn.Open()
command.ExecuteNonQuery()
Form1.Timer1.Enabled = True
clearfields()
Form1.Timer1.Enabled = False
Me.Close()
End If
cnn.Close()
End Sub
It says that the error is located here: (ID is an Autonumber.)
Dim str As String = ("DELETE FROM TableName WHERE ID= " & ComboBox1.Text & "")
Thank you so much!