I have this datatable saved in cache
DataTable dataTable = ReportsBLL.GetProducts() as DataTable;
HttpContext.Current.Cache["productinfokey"] = dataTable;
System.Web.HttpContext.Current.Cache.Insert("productinfokey", dataTable, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
Sometimes I need to filter datatable as
dataTable.Select("CreateDate >= " + DateTime.Now.AddMonths(-3) + " and CreateDate <= " + DateTime.Now + "")
but how can I filter data by those property because this way give me error
Syntax error: Missing operand after '05' operator.
datatable filled from
DataTable table = new DataTable();
try
{
SqlCommand cmd = (SqlCommand).Database.Connection.CreateCommand();
cmd.CommandText = "[dbo].[Report_Get]";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@parmCategory", parmCategory);
try
{
Connection.Open();
var reader = cmd.ExecuteReader();
table.Load(reader);
return table;
}
catch { /*some other code*/ }
}
catch { /*some other code*/ }
What is wrong here and how can I solve this?