c#里面datatable删除rows出现异常的问题
string strQueryString = "select * from gx_xtczy ";
SqlDataAdapter sqlDA = new SqlDataAdapter(strQueryString, sqlConn);
DataSet ds = new DataSet();
sqlDA.Fill(ds, "dt1 ");
DataTable dt = ds.Tables[ "dt1 "];
for (int j = 0; j < 3; j++)
{
int x = dt.Rows.Count - 1;
for (int i = 0; i < x ; i++)
{
if (i % 2 == 1)
{
try
{
dt.Rows[i].Delete();
break;
}
catch (Exception ex)
{ }
}
}