Execute Non Query on Access Table
Executes a non-query SQL command (such as INSERT, UPDATE, or DELETE) on a Microsoft Access database.
This function ensures that the connection is open before executing the command. It does not throw or log exceptions but returns 0 silently in case of failure.
VB
Public Function ExecuteNonQueryOnAccessTable(MyConnection As OleDb.OleDbConnection,
SqlCmd As String) As Integer
Try
If Not MyConnection.State = ConnectionState.Open Then MyConnection.Open()
Dim MyCmd As New OleDb.OleDbCommand(SqlCmd, MyConnection)
Return MyCmd.ExecuteNonQuery()
Catch ex As Exception
Return 0
End Try
End Function