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 compiler level does not match the version of the installed Java Project facet.
    Project configuration is not up-to-date with pom.xml. Select: Maven->Update Project... from the project context menu or use Quick Fix.
    JavaScript
    JavaScript
    Eclipse
    Eclipse
    Oracle
    Java
    Ext JS 4.2
    Eclipse
  • 原文地址:https://www.cnblogs.com/zhuawang/p/2040396.html
Copyright © 2011-2022 走看看