I believe many programmers in Visual basic 2015 are asking themselves how to delete all records in a table at once without looping or similar.
Let say we have a Microsoft Access Database called "Test.accdb". We also have a table called "Test_Table". Let say the table has 5000 records and we need to delete all of them at once.
Here is the Visual Basic 2015 code?
Dim conn As OleDbConnection
Dim ClearAllData As OleDbCommand
conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=..\Test.accdb; Persist Security Info=False;")
Dim sql = "DELETE * FROM [Test_Table]"
conn.Open()ClearAllData = New OleDbCommand(sql, conn)ClearAllData.ExecuteNonQuery()
No comments:
Post a Comment