zoukankan      html  css  js  c++  java
  • 以字符串变量作为缓存依赖,缓存数据

     protected void Page_Load(object sender, EventArgs e)
            {
               
            }

            protected void TextBoxIntelligent1_Focus(object sender, wzh.myWebControlsLib.TextBoxIntelligent.FocusEventArgs e)
            {
                string arg = e.tbText;
                if (Cache["dep"] == null)
                {
                    Cache["dep"] = arg;
                }
                else if ((string)Cache["dep"] != arg)
                {
                    Cache["dep"] = arg;
                }

                String[] dependencyKey = new String[1];
                dependencyKey[0] = "dep";
                CacheDependency dependency = new CacheDependency(null, dependencyKey);

                if (Cache["Data"] == null)
                {
                    Cache.Insert("Data", getData(arg), dependency);
                }

                TextBoxIntelligent1.DataTable = (DataTable)Cache["Data"];

            }

            public DataTable getData(string arg)
            {
                SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["sqlConn"]);
                con.Open();
                SqlDataAdapter ad = new SqlDataAdapter("select [name] from tb_name where [name] like'" + arg + "%'", con);
                DataSet ds = new DataSet();
                ad.Fill(ds, "city");
                DataTable dt = ds.Tables["city"];
                con.Close();
                ad.Dispose();
                return dt;
            }

  • 相关阅读:
    DES介绍
    jsp知识点
    浏览器地址传中文
    cookie
    null与“ ”的区别
    验证二叉查找树 · Validate Binary Search Tree
    二叉树中的最大路径和 · Binary Tree Maximum Path Sum
    最近公共祖先 · Lowest Common Ancestor
    平衡二叉树Balanced Binary Tree
    二叉树的最大/小/平衡 深度 depth of binary tree
  • 原文地址:https://www.cnblogs.com/zhuawang/p/2040396.html
Copyright © 2011-2022 走看看