zoukankan      html  css  js  c++  java
  • Cache使用方法1

    代码
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ypxt.IDAL;
    using System.Data;
    using System.Data.SqlClient;
    using ypxt.MODEL;
    using ypxt.DBUtility;
    namespace ypxt.SQLDAL
    {
      
    public  class DALKey: IKey
        {
            
    private const string PARM_KeyId = "@KeyId";
            
    private const string PARM_KeyText = "@KeyText";
            
    private const string PARM_AdverId = "@AdverId";
            
    private const string PARM_Money = "@Money";

            
    private const string ADD_Keyinfo = "Insert into Key(KeyText,AdverId,Money) values(" + PARM_KeyText + "," + PARM_AdverId + "," + PARM_Money + ")";
            
    private const string UPDATE_Keyinfo = "UPDATE Key SET KeyText=" + PARM_KeyText + ",AdverId=" + PARM_AdverId + ",Money=" + PARM_Money + " WHERE CorpId=" + PARM_KeyId;
            
    private const string DELETE_KeyinfoByID = "DELETE FROM Key WHERE KeyId=" + PARM_KeyId;
            
    private const string SELECT_KeyinfoByID = "SELECT * FROM Key WHERE KeyId=" + PARM_KeyId;
            
    private const string SELECT_Keyinfo = "SELECT * FROM Key";
     
         
    /// 增加数据 ---郑
         #region 

            
    public bool addKeyinfo(Keyinfo Keyinfo)
           {
               SqlParameter[] param 
    = GetKeyinfoParameters();
               setKeyinfoParameters(param, Keyinfo);
               
    int result = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.Text, ADD_Keyinfo, param);
               
    if (result == 0)
               {
                   
    return false;
               }
               
    return true;
           }
            
    public static SqlParameter[] GetKeyinfoParameters()
            {
                
    //从缓存里面取参数,如果缓存里面没有参数,就将 参数加入缓存里面,,)
                SqlParameter[] param = SqlHelper.GetCachedParameters(ADD_Keyinfo);//.GetCachedParameters(ADD_MEMBERINFO);//从缓存里面取数据
                
    //将参数加入缓存里面
                if (param == null)
                {
                    
    /// 创建各个参数
                    param = new SqlParameter[]{
                     
    new SqlParameter(PARM_KeyText,SqlDbType.NVarChar,50),
                     
    new SqlParameter(PARM_AdverId,SqlDbType.Int,30),
                     
    new SqlParameter(PARM_Money,SqlDbType.Decimal,30)                
                    };
                    
    //放入缓存
                    SqlHelper.CacheParameters(ADD_Keyinfo, param);
                }
                
    return param;
            }

            
    public static void setKeyinfoParameters(SqlParameter[] parms, Keyinfo Keyinfo)
            {
                parms[
    0].Value = Keyinfo.KeyText;
                parms[
    1].Value = Keyinfo.AdverId;
                parms[
    2].Value = Keyinfo.Money;
               
            }
           
    #endregion
           
    #region      
            
    public bool updateKeyinfo(Keyinfo Keyinfo)
          {
              
    return true;
          }
           
    #endregion
            
    public bool deleteKeyinfo(int KeyinfoID)
          {
              
    return true;
          }
     
        }
    }
  • 相关阅读:
    Maven仓库是什么
    什么是Maven
    Shiro 的优点
    shiro有哪些组件
    Python偶斐波那契数
    Python求1000以内所有3或5的倍数的和。
    python"TypeError: 'NoneType' object is not iterable"错误解析
    python中列表常用的几个操作函数
    反射类的一些基本用法
    循环随机数短时间内大多都是重复的问题
  • 原文地址:https://www.cnblogs.com/muer/p/1724684.html
Copyright © 2011-2022 走看看