public IDatabase CreateDatabase(string databaseName)
        {
            SqlServerBatch batch =
                new SqlServerBatch(
                    String.Format(
                        @"CREATE DATABASE {0};",
                        TransactSqlHelpers.Identifiers.ValidIdentifier(databaseName)));

            _masterDatabase.ExecuteSqlBatch(batch);

            Exception lastBatchExecutionException = batch.Executions.Last().Exception;

            if (lastBatchExecutionException != null)
                throw new ApplicationException("Database creation failed.", lastBatchExecutionException);

            return new SqlServerDatabase(this.ConnectionString(databaseName));
        }
Example #2
0
        public IDatabase CreateDatabase(string databaseName)
        {
            SqlServerBatch batch =
                new SqlServerBatch(
                    String.Format(
                        @"CREATE DATABASE {0};",
                        TransactSqlHelpers.Identifiers.ValidIdentifier(databaseName)));

            _masterDatabase.ExecuteSqlBatch(batch);

            Exception lastBatchExecutionException = batch.Executions.Last().Exception;

            if (lastBatchExecutionException != null)
            {
                throw new ApplicationException("Database creation failed.", lastBatchExecutionException);
            }

            return(new SqlServerDatabase(this.ConnectionString(databaseName)));
        }