im having a problem on double execution, this is a part of audit trail on my system, the DELETE FUNCTION is working, but it aint updating, im getting an error - it says that "Syntax Error on update statement" on i tried to manually query it on my access and it is working
Dim burahin As String
burahin = MsgBox("Are you sure you want to delete a customer from the database", vbOKCancel + vbQuestion, "Administrator")
If burahin = vbOK Then
Dim delet = "UPDATE audit SET action= 'DELETED A CUSTOMER' WHERE pk_id = " + TextBox5.Text + ""
Dim Sql = "Delete from customer where customer_ID= " + TextBox1.Text + ""
cmd = New OleDbCommand(Sql, connection)
cmd2 = New OleDbCommand(delet, connection)
Dim affectedRecord As Integer
[b]Dim affectedRecord2 As Integer[/b]
Try
connection.Open()
affectedRecord = cmd.ExecuteNonQuery
If affectedRecord = 0 Then
MessageBox.Show("No Record was Updated")
Else
MsgBox("Customer Deleted", MsgBoxStyle.Information, "Administrator")
Call textdb2clear()
DataGridView1.DataSource = Nothing
sql2.Fill(db1, "customer")
DataGridView1.DataSource = db1.Tables(0)
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
connection.Close()
connection.Open()
Try
affectedRecord2 = cmd2.ExecuteNonQuery
If affectedRecord2 = 0 Then
MessageBox.Show("No Record was Updated")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
If connection.State <> ConnectionState.Closed Then
connection.Close()
End If
End If