G Guest Aug 19, 2005 #1 I insert into the cache: if (Cache["testQuestion"+ i] == null) { Cache.Insert("testQuestion"+ i, ds.Tables); }
I insert into the cache: if (Cache["testQuestion"+ i] == null) { Cache.Insert("testQuestion"+ i, ds.Tables); }
G Grant Merwitz Aug 19, 2005 #2 Maybe the Cache["testQuestion"+ i] is not null? try if (Cache["testQuestion"+ i] == null) { Cache.Insert("testQuestion"+ i, ds.Tables); } else Response.Write("CACHE IS NOT NULL");
Maybe the Cache["testQuestion"+ i] is not null? try if (Cache["testQuestion"+ i] == null) { Cache.Insert("testQuestion"+ i, ds.Tables); } else Response.Write("CACHE IS NOT NULL");
G Guest Aug 19, 2005 #3 I checked, it is not null. I have added more code below, on how i insert and then retrieve frm the cache. The error is not in the inserting but in the retrieving frm the cache. I insert into the cache: Eg. i = 1. if (Cache["testQuestion"+ i] == null) { Cache.Insert("testQuestion"+ i, ds.Tables) } else lbl2.Text += "CACHE IS NOT NULL"; retrieve from the cache: DataSet ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]]; <------ if (ds2 != null) { ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]]; MyRepeater.DataSource = ds.Tables[(int)ViewState["QnNo"]]; MyRepeater.DataBind(); } I get the error: "Specified cast is not valid". TIA.
I checked, it is not null. I have added more code below, on how i insert and then retrieve frm the cache. The error is not in the inserting but in the retrieving frm the cache. I insert into the cache: Eg. i = 1. if (Cache["testQuestion"+ i] == null) { Cache.Insert("testQuestion"+ i, ds.Tables) } else lbl2.Text += "CACHE IS NOT NULL"; retrieve from the cache: DataSet ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]]; <------ if (ds2 != null) { ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]]; MyRepeater.DataSource = ds.Tables[(int)ViewState["QnNo"]]; MyRepeater.DataBind(); } I get the error: "Specified cast is not valid". TIA.
G Grant Merwitz Aug 19, 2005 #4 yes, of course you casting it to a dataset when it is infact a datatable so either Cache.Insert("testQuestion"+ i, ds) or better yet DataTable dt2 = (DataTable)Cache["testQuestion"+ (int)ViewState["QnNo"]]; because ds.Tables is infact a DataTable in a DataSet
yes, of course you casting it to a dataset when it is infact a datatable so either Cache.Insert("testQuestion"+ i, ds) or better yet DataTable dt2 = (DataTable)Cache["testQuestion"+ (int)ViewState["QnNo"]]; because ds.Tables is infact a DataTable in a DataSet