You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.3 KiB

  1. using System;
  2. using System.Configuration;
  3. namespace DBUtility
  4. {
  5. public class PubConstant
  6. {
  7. /// <summary>
  8. /// 獲取連接字符串
  9. /// </summary>
  10. public static string ConnectionString
  11. {
  12. get
  13. {
  14. string _connectionString = ConfigurationManager.AppSettings["ConnectionString"];
  15. string ConStringEncrypt = ConfigurationManager.AppSettings["ConStringEncrypt"];
  16. if (ConStringEncrypt == "true")
  17. {
  18. _connectionString = DESEncrypt.Decrypt(_connectionString);
  19. }
  20. return _connectionString;
  21. }
  22. }
  23. /// <summary>
  24. /// 得到web.config裏配置項的資料庫連接字符串
  25. /// </summary>
  26. /// <param name="configName"></param>
  27. /// <returns></returns>
  28. public static string GetConnectionString(string configName)
  29. {
  30. string connectionString = ConfigurationManager.AppSettings[configName];
  31. string ConStringEncrypt = ConfigurationManager.AppSettings["ConStringEncrypt"];
  32. if (ConStringEncrypt == "true")
  33. {
  34. connectionString = DESEncrypt.Decrypt(connectionString);
  35. }
  36. return connectionString;
  37. }
  38. }
  39. }