Operations: Server: How to Enable or Disable a Database
To enable or disable a database, use the ToggleDatabasesStateOperation
.
Syntax
public ToggleDatabasesStateOperation(string databaseName, bool disable)
public ToggleDatabasesStateOperation(string[] databaseNames, bool disable)
Parameters
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);
store.Maintenance.Server.Send(toggleOperation);
Example II
// enable Foo and Bar databases
ToggleDatabasesStateOperation toggleOperation =
new ToggleDatabasesStateOperation(new [] { "Foo", "Bar" },
disable: false);
store.Maintenance.Server.Send(toggleOperation);
Please enable JavaScript to view the comments powered by Disqus.