Winform缓存

 public partial class Form3 : Form
    {

        //缓存类
        System.Web.Caching.Cache cache;
        public Form3()
        {
            InitializeComponent();

            string SQL = "select  top 1000 * from infomation";

            DataTable datatable = DBHelper.GetDataTable(SQL, ConnType.Menu);
            dataGridView1.DataSource = datatable;

            cache = System.Web.HttpRuntime.Cache;
            cache.Insert("infomation", datatable);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (cache != null) {
                DataTable table = cache["infomation"] as DataTable;
                dataGridView2.DataSource = table;
            }            
        }

}

posted @ 2012-12-22 00:26  rongnianwu  阅读(314)  评论(0编辑  收藏  举报