SqlConnection::ChangeDatabase Method (String^)
.NET Framework (current version)
Changes the current database for an open SqlConnection.
Assembly: System.Data (in System.Data.dll)
Parameters
- database
-
Type:
System::String^
The name of the database to use instead of the current database.
Implements
IDbConnection::ChangeDatabase(String^)| Exception | Condition |
|---|---|
| ArgumentException | The database name is not valid. |
| InvalidOperationException | The connection is not open. |
| SqlException | Cannot change the database. |
The value supplied in the database parameter must be a valid database name. The database parameter cannot contain a null value, an empty string, or a string with only blank characters.
The following example creates a SqlConnection and displays some of its read-only properties.
.NET Framework
Available since 1.1
Available since 1.1
Show: