Beispiel #1
0
 /// <summary>
 /// 构造函数,初始化类实例
 /// </summary>
 public DbHelper()
 {
     try
     {
         bool   tempConStringEncrypt = Convert.ToBoolean(ConfigurationManager.AppSettings["ConStringEncrypt"]);
         string tempConString        = string.Empty;
         if (tempConStringEncrypt == true)
         {
             tempConString  = ConfigurationManager.AppSettings["ConCiphertextString"].ToString();
             this.ConString = DbEncrypt.DESDecrypt(tempConString, "SIMByZMM");
         }
         else
         {
             this.ConString = ConfigurationManager.AppSettings["ConExpresslyString"].ToString();
         }
         this.mySqlConnection = new SqlConnection(this.ConString);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #2
0
 /// <summary>
 /// 获取连接字符串
 /// </summary>
 private static string GetConnectionString()
 {
     try
     {
         bool   tempConStringEncrypt = Convert.ToBoolean(ConfigurationManager.AppSettings["ConStringEncrypt"]);
         string returnConString = string.Empty, tempConString = string.Empty;
         if (tempConStringEncrypt == true)
         {
             tempConString = ConfigurationManager.AppSettings["ConCiphertextString"].ToString();
             AssemblyAttribute tempAACall = new AssemblyAttribute();
             string            tempKey    = tempAACall.AssemblyDescription + "By" + tempAACall.AssemblyCompany;
             returnConString = DbEncrypt.DESDecrypt(tempConString, tempKey);
         }
         else
         {
             returnConString = ConfigurationManager.AppSettings["ConExpresslyString"].ToString();
         }
         return(returnConString);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }