You can delete a record by calling Resultset.Delete() with either an index, or a record object:
If you want to remove all the resultset's records at once call Resultset.Clear():
Deleting multiple records in a loop
Read this part carefully when you plan to delete multiple records in a loop or a foreach enumeration.
Deleting a single Record in a for or foreach is not a problem.
Enumerating will not work:
EmployeesRecordset rs = new EmployeesRecordset();
foreach (var record in rs)
You expect the enumeration to end with a rs.RecordCount of 0, but instead you end up with 3 records left in the resultset. This is because rs.Delete() changes the length of the list you are enumerating with foreach, and that confuses the enumerator.
A regular for loop also doesn't work.
The solution is to use a reverse for loop. Only a reverse loop will delete multiple records correctly:
for (int x = rs.RecordCount - 1; x >= 0; x--)
EmployeesRecord record = rs[x];
rs.Delete(x); // or rs.Delete(record);
Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single source