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

  • 相关阅读:
    每日总结2021.9.14
    jar包下载mvn
    每日总结EL表达语言 JSTL标签
    每日学习总结之数据中台概述
    Server Tomcat v9.0 Server at localhost failed to start
    Server Tomcat v9.0 Server at localhost failed to start(2)
    链表 java
    MVC 中用JS跳转窗体Window.Location.href
    Oracle 关键字
    MVC 配置路由 反复走控制其中的action (int?)
  • 原文地址:https://www.cnblogs.com/zhuawang/p/2040396.html
Copyright © 2011-2022 走看看