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