// Delete is not really deleted. It only changes the rowstate of the row to rowstate. Delete (there are still so many rows. Count)
// Remove is actually deleted from the datatable
For example:
DS. Tables [0]. Rows [I]. Delete ();
DS. Tables [0]. Rows. removeat (I );
The two are different.
1. Use mydatatable. Rows. removeat (I) to delete rows.
2. To use mydatatable. Rows (I). Delete, you must use mydatatable. acceptchanges to update the data to the database.
The first method is relatively simple. but do not use mydatatable in the loop. rows. removeat (I ). because after each row is deleted. the I value increases, but the number of rows decreases. this will definitely cause errors.
Therefore, you need to traverse the data in reverse order when using the Remove Method.
Int COUNT = Ds. Tables [0]. Rows. count;
For (INT I = count-1; I> = 0; I --)
{
DS. Tables [0]. Rows. removeat (I );
}