locked
DataSet stored in the Cache missing all data when retrieved RRS feed

  • Question

  • User1580150979 posted

     

    We have an ASP.NET 4.0 application where we create a dataset during runtime and then later store in the Cache

     

                    theCache.Insert
                        (
                            "NASLUNS",
                            All_LUNS,
                            null,
                            DateTime.Now.AddSeconds(30.00),
                            Cache.NoSlidingExpiration,
                            System.Web.Caching.CacheItemPriority.Default,
                            new System.Web.Caching.CacheItemRemovedCallback(ItemLUNSRemoved)
                        );

     

    After creating it, we retrieve it from another page.   We get back the DataSet object and its contained tables but they are all empty.    The debugger shows it fully populated when we store it.

     

    What are we missing?

     

    Thanks,

    Nikos

     

    Friday, October 28, 2011 3:22 PM

Answers

  • User612574037 posted

    Hi,

    I suppose there may be something wrong with the parameter in the Cache.Insert() method. You have used the parameter "DateTime.Now.AddSeconds(30.00)," in your code. It means when the object expires and it will be removed from the cache. You can try to set a longer time such as "DateTime.Now.AddMinutes(2),". You can learn more about the Cache.Insert() method in the below link.

    http://msdn.microsoft.com/en-us/library/05kd8d77.aspx

    Hope it can help you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 3, 2011 11:32 AM

All replies

  • User-1488931086 posted

    Hey!~

    How did you store data from db into DataSet?

    I'm also afraid there's something related with Cache, which doesn't belong to Data forum... Maybe you can also go to http://forums.asp.net/

    Sunday, October 30, 2011 2:31 AM
  • User612574037 posted

    Hi,

    I suppose there may be something wrong with the parameter in the Cache.Insert() method. You have used the parameter "DateTime.Now.AddSeconds(30.00)," in your code. It means when the object expires and it will be removed from the cache. You can try to set a longer time such as "DateTime.Now.AddMinutes(2),". You can learn more about the Cache.Insert() method in the below link.

    http://msdn.microsoft.com/en-us/library/05kd8d77.aspx

    Hope it can help you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 3, 2011 11:32 AM