views:

102

answers:

0

I am using IIS7 and c# and mysql. and I put some objects into asp.net cache system with sql keywords. it has very simple logic.put the selected dataset into cache with the given sql keyword.

here is the problem. when I call my site with www.abc.com it works normal. while surfing in abc.com after second click firstly filled dataset becomes empty datasets and my site start showing empty lists.

I tried changing keys to some static words and copy datasets then cache them but no success so far.

I hope I explained well. http://beta.mpazari.com is the place if you like to see and at red boxes dropdowns is the lists should have been filled with data.

here is the my fill function

public void Fill(ref DataSet ds, string sql, DateTime? cacheTime, string key)
    {
        if (key == null) key = sql;
        if (cacheTime == null) cacheTime = DateTime.Now.AddMinutes(generalCacheExpiarionTimeInMinutes);
        if (cache[key] != null) { ds = (DataSet)cache[key]; return; }
        MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["motorConnectionString"].ConnectionString);
        try
        {
            conn.Open();
            MySqlDataAdapter myda = new MySqlDataAdapter(sql, conn);
            if (ds == null) ds = new DataSet();

            ds.Clear();
            myda.Fill(ds);
            cache.Insert(key, ds.Copy(), null, cacheTime.Value, System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.NotRemovable,null);
        }
        finally
        {
            conn.Close();
        }
    }

thanks in advance.