Esempio n. 1
0
        /// <summary>
        /// Reads the application connection   string from Config database
        /// </summary>
        /// <param name="connectionStringID">value of connectionStringID</param>
        /// <returns>application connection   string</returns>
        private static string GetApplicationConnectionStringFromDB(string connectionStringID)
        {
            string configDatabaseConnectionString = null;
            string applicationConnectionString    = null;

            configDatabaseConnectionString = GetDatabaseConnectionStringFromRegistry(CONFIGSDATABASEKEY);

            Database database = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(configDatabaseConnectionString);

            using (DbCommand cmd = database.GetStoredProcCommand(CONFIGURATIONCONNECTIONSTRINGGET))
            {
                database.AddInParameter(cmd, "@connectionStringKey", DbType.AnsiString, connectionStringID);
                database.AddOutParameter(cmd, "@connectionStringValue", DbType.AnsiString, 8000);
                database.ExecuteNonQuery(cmd);
                applicationConnectionString = (string)database.GetParameterValue(cmd, "@connectionStringValue");
            }

            return(applicationConnectionString);
        }