1
我想通过我的数据库循环查找具有日期范围的特定行。 每当我尝试使用DataTable.Import(DataRow)时,它会添加一个没有值的新行。 如何将DataRow“导入”DataTable? 这是循环,谢谢!将DataRow对象添加到C#中的DataTable中#
public DataTable FilterDataTableByDates(DataTable td, DateTime from, DateTime to)
{
DataTable tempTd = new DataTable();
foreach (DataRow dr in td.Rows)
{
long ticks = Convert.ToInt64(dr["cpd_date"].ToString());
if (ticks > from.Ticks && ticks < to.Ticks)
{
tempTd.ImportRow(dr);
}
}
return tempTd.Copy();
}
谢谢老兄你摇滚 – user1326293 2012-04-22 10:17:23