I want to write a simple code line that will delete all the datarows in a certain Table.
(Working with c# and MS Access 2010)
The table contains about 1000 rows, 10 columns, and it gets a bit slow.
This code does the job:
connStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Words\shinunonDB.accdb;Persist Security Info=False;";
OleDbConnection Conn = new OleDbConnection();
Conn.ConnectionString = connStr;
sql = "select * from Heb";
Conn.Open();
OleDbDataAdapter da = new OleDbDataAdapter(sql, Conn);
DataSet ds = new DataSet();
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
da.Fill(ds, "Heb");
foreach (DataRow dRow in ds.Tables["heb"].Rows)
{
dRow.Delete();
}
da.Update(ds, "heb");
But I guess there might be a shorter and more efficient way to do it.
Thank you guys.
Yes, there is. Just use a SQL command:
You can issue a SQL command on a OleDbConnection. Something like this: