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;
            }

  • 相关阅读:
    Java——GUI
    linux变量
    shell脚本
    linux查找文件命令
    composer的安装
    restful的nginx配置方法
    api调用安全
    PHP设置Cookie的HTTPONLY属性
    php的异常处理
    php错误报告
  • 原文地址:https://www.cnblogs.com/zhuawang/p/2040396.html
Copyright © 2011-2022 走看看