SqlCeConnection::ChangeDatabase Method
Changes the current database for an open SqlCeConnection.
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)
Parameters
- value
- Type: System::String
The database name.
Implements
IDbConnection::ChangeDatabase(String)| Exception | Condition |
|---|---|
| ArgumentException | The database name is not valid. |
| InvalidOperationException | The connection is not open. |
| SqlCeException | The databases cannot be changed. |
The name supplied in the value parameter must be a valid database name. The name must be the full path to the database; for example, "\my app\myDB.sdf". The value parameter cannot be nullptr, be empty, or contain a string with only blank characters.
ChangeDatabase applies to the new database the same properties used to open the current database, except for the password, which will be set to an empty string.
If the new database requires a password, this call will fail. If this occurs, to change databases, you must close the original connection, specify a new connection string, and then reopen the connection.