Exemplo n.º 1
0
        public virtual string GetConnectionString(string dbName)
        {
            string conStr = this.ConnectionString;

            System.Data.SqlClient.SqlConnectionStringBuilder csb = new System.Data.SqlClient.SqlConnectionStringBuilder(conStr);
            csb.InitialCatalog = dbName;
            conStr             = csb.ConnectionString;
            csb.Clear();
            csb = null;

            return(conStr);
        }
Exemplo n.º 2
0
 public string getEFConnStr()
 {
     /*初始化*/
     System.Data.SqlClient.SqlConnectionStringBuilder objSCSB = null;
     try
     {
         objSCSB                = new System.Data.SqlClient.SqlConnectionStringBuilder();
         objSCSB.DataSource     = DecryptOfTripleDES(ConfigurationManager.AppSettings["SqlSvrIP"].ToString());
         objSCSB.InitialCatalog = DecryptOfTripleDES(ConfigurationManager.AppSettings["InitialDB"].ToString());
         objSCSB.UserID         = DecryptOfTripleDES(ConfigurationManager.AppSettings["SqlDBAcct"].ToString());
         objSCSB.Password       = DecryptOfTripleDES(ConfigurationManager.AppSettings["SqlDBPwd"].ToString());
         return(objSCSB.ConnectionString);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         objSCSB.Clear();
         objSCSB = null;
     }
 }