在DataTable中执行Select("条件")后,返回DataTable的方法


网上看到一个解决方法,感觉不错:

private DataTable GetNewDataTable(DataTable dt,string condition)
{
DataTable newdt = new DataTable();
newdt=dt.Clone();
DataRow[] dr = dt.Select(condition);
for(int i=0;i<dr.Length;i++)
{
newdt.ImportRow((DataRow)dr[i]);
}
return newdt; //返回的查询结果
}
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3