遍历DataTbale并检测是否有重复行
public bool CheckDataSet(DataTable tablename,string filename)
{
DataTable dt = tablename;
int i = dt.Rows.Count-1;
while(i>=0)
{
for(int j = 0; j<=i-1; j++)
{
if(dt.Rows[j][filename].ToString() == dt.Rows[i][filename].ToString())
{
return false;
}
}
i--;
}
return true;
}
filename是需要检测的字段
{
DataTable dt = tablename;
int i = dt.Rows.Count-1;
while(i>=0)
{
for(int j = 0; j<=i-1; j++)
{
if(dt.Rows[j][filename].ToString() == dt.Rows[i][filename].ToString())
{
return false;
}
}
i--;
}
return true;
}