I have this situation: I have to create a dataset that takes all data from another dataset. In some cases I have to remove some rows from each of the new dataset. When both foreach cycles are finished, both datasets are empty, even when finish only the first, the first dataset has some rows.
Any idea why, ... or tell where I have code wrong.
Thnx in advance.
//Dataset comes as a parameter.
DataSet dsFirst = ds;
DataSet dsSecond = ds;
foreach (DataRow dr in dsFirst.Tables[0].Select())
{
int i = Convert.ToInt32(dr["ROWNUMBER"]);
//merren vetem veprimet ATM qe jane bere para CoB
if (i > x && i < y)
dr.Delete();
else
dr["NOVATRANSAKCIJA"] = 0;//eshte derguar njehere, per rrjedhoje nuk do te dergohet sms
}
dsFirst.AcceptChanges();
foreach (DataRow dr1 in dsSecond.Tables[0].Select())
{
int i = Convert.ToInt32(dr1["ROWNUMBER"]);
//merren veprimet e sistemit dhe veprimet ATM te bera gjate CoB
if (i < x || i > y)
dr1.Delete();
else
dr1["NOVATRANSAKCIJA"] = 1;//nuk eshte derguar asnjehere, per rrjedhoje do te dergohet sms
}
dsSecond.AcceptChanges();