I'm trying to loop through my database looking for specific rows with date ranges. Whenever I try to use DataTable.Import(DataRow) it adds a new row with no values inside. How do I "import" a DataRow into a DataTable? Here is the loop, thanks!
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();
}