Esempio n. 1
0
        public static DbConnection GetDbConnection(DatabaseConnectionDetail connectionDetail)
        {
            if (string.IsNullOrWhiteSpace(connectionDetail.ConnectionString))
            {
                throw new ArgumentNullException(Properties.Resources.ERROR_ConnectionStringEmpty);
            }
            if (string.IsNullOrWhiteSpace(connectionDetail.LogInUserId))
            {
                throw new ArgumentNullException(Properties.Resources.ERROR_UserIdEmpty);
            }
            if (string.IsNullOrWhiteSpace(connectionDetail.LogInPassword))
            {
                throw new ArgumentNullException(Properties.Resources.ERROR_PasswordEmpty);
            }

            var formatedString = string.Format(connectionDetail.ConnectionString,
                                               connectionDetail.DatabaseServerName,
                                               connectionDetail.DatabaseServerPort,
                                               connectionDetail.LogInUserId,
                                               connectionDetail.LogInPassword,
                                               connectionDetail.DatabaseName);

            return(Activator.CreateInstance(connectionDetail.ConnectionType, formatedString) as DbConnection);
        }
Esempio n. 2
0
 public DbManager(DatabaseConnectionDetail ConnectionDetail)
 {
     connectionDetail = ConnectionDetail;
 }