Operations: Server: How to Enable or Disable a Database

To enable or disable a database, use the ToggleDatabasesStateOperation.


public ToggleDatabasesStateOperation(string databaseName, bool disable)

public ToggleDatabasesStateOperation(string[] databaseNames, bool disable) 
databaseName string Name of database to toggle state
disable bool True, if database should be disabled, False is database should be enabled
Return Value
Disabled bool If database was disabled
Name string Name of the database
Success bool If request succeed
Reason string The reason for success or failure.

Example I

// disable Northwind database
ToggleDatabasesStateOperation toggleOperation = 
    new ToggleDatabasesStateOperation("Northwind", 
        disable: true);

Example II

// enable Foo and Bar databases
ToggleDatabasesStateOperation toggleOperation = 
    new ToggleDatabasesStateOperation(new [] { "Foo", "Bar" }, 
        disable: false);