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
43 lines
1.3 KiB
using System;
|
|
using System.Configuration;
|
|
|
|
namespace DBUtility
|
|
{
|
|
public class PubConstant
|
|
{
|
|
/// <summary>
|
|
/// 獲取連接字符串
|
|
/// </summary>
|
|
public static string ConnectionString
|
|
{
|
|
get
|
|
{
|
|
string _connectionString = ConfigurationManager.AppSettings["ConnectionString"];
|
|
string ConStringEncrypt = ConfigurationManager.AppSettings["ConStringEncrypt"];
|
|
if (ConStringEncrypt == "true")
|
|
{
|
|
_connectionString = DESEncrypt.Decrypt(_connectionString);
|
|
}
|
|
return _connectionString;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 得到web.config裏配置項的資料庫連接字符串
|
|
/// </summary>
|
|
/// <param name="configName"></param>
|
|
/// <returns></returns>
|
|
public static string GetConnectionString(string configName)
|
|
{
|
|
string connectionString = ConfigurationManager.AppSettings[configName];
|
|
string ConStringEncrypt = ConfigurationManager.AppSettings["ConStringEncrypt"];
|
|
if (ConStringEncrypt == "true")
|
|
{
|
|
connectionString = DESEncrypt.Decrypt(connectionString);
|
|
}
|
|
return connectionString;
|
|
}
|
|
|
|
|
|
}
|
|
}
|