public void SingleUserMode() { _database.DatabaseOptions.UserAccess = DatabaseUserAccess.Single; _database.Alter(TerminationClause.RollbackTransactionsImmediately); }
private static void FinishRestore(DatabaseRestoreRequest request, Database database, Server server) { // After the restore, ensure the recovery model is set to simple. // Since we only support DEV/TEST/DEMO, we dont want the overhead of the other recovery models. database.RecoveryModel = RecoveryModel.Simple; database.Alter(); string sqlConnectionString = string.Format("Integrated Security=SSPI;Persist Security Info=True;Initial Catalog={1};Data Source={0}", server.Name, database.Name); foreach (var script in request.ScriptsToExecute) { var fileInfo = new FileInfo(script); string sql; using (var text = fileInfo.OpenText()) { sql = text.ReadToEnd(); text.Close(); } SqlConnection connection = new SqlConnection(sqlConnectionString); Server srv = new Server(new ServerConnection(connection)); srv.ConnectionContext.SqlExecutionModes = SqlExecutionModes.ExecuteAndCaptureSql; srv.ConnectionContext.ExecuteNonQuery(sql); } }
public void RestrictedUserMode() { _database.DatabaseOptions.UserAccess = Smo.DatabaseUserAccess.Restricted; _database.Alter(Smo.TerminationClause.RollbackTransactionsImmediately); }