Below is my code which am calling and am getting below exception. Collection was modified; enumeration operation might not execute.
In this code am checking if dataset contains tb_error table name and then checking the row count. If rowcount> 1 , insert into db. after that i want to clear that table and after that i need to clear other view also. Please help me where to modify my code.
if (MainClass.OutputDataset.Tables.Contains(tb_error.TableName))
{
foreach (DataRow drErr in MainClass.OutputDataset.Tables[tb_error.TableName].Rows)
{
//insert into DB
}
}
if (MainClass.OutputDataset != null && MainClass.OutputDataset.Tables["tb_error"].Rows.Count > 0)
{
MainClass.OutputDataset.Tables["tb_error"].Clear();
}
MainClass.dsinput.Tables.Remove("BSData_VW");
}