Let the storm money come!

简单缓存 datatable

            DataTable dt = new DataTable();

            if (Cache["mytablecache"] == null)
            {
                using (SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=LocalDB;Integrated Security=True"))
                {
                    con.Open();
                    SqlDataAdapter adapter = new SqlDataAdapter("SELECT top 100 * FROM [Money_CostDetail]", con);
                    adapter.Fill(dt);
                }
                Cache.Insert("mytablecache", dt, null, DateTime.UtcNow.AddMinutes(1), TimeSpan.Zero);
            }
            else
            {
                dt = Cache["mytablecache"as DataTable;
            }
posted @ 2012-02-22 21:10  精密~顽石  阅读(903)  评论(0编辑  收藏  举报
在通往地狱的路上,加班能使你更快到达。