SqlCeConnection.ChangeDatabase Method

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Changes the current database for an open SqlCeConnection.

  [Visual Basic]
  Public Overridable Sub ChangeDatabase( _
   ByVal 
  value
   As String _
) Implements IDbConnection.ChangeDatabase
[C#]
public virtual void ChangeDatabase(string value
);
[C++]
public: virtual void ChangeDatabase(String* value
);
[JScript]
public function ChangeDatabase(
   value : String);

Parameters

  • value
    The database name.

Return Value

true if the database was changed successfully; otherwise, false.

Implements

IDbConnection.ChangeDatabase

Exceptions

Exception Type Condition
ArgumentException The database name is not valid.
InvalidOperationException The connection is not open.
SqlCeException The databases cannot be changed.

Remarks

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 contain a null value, 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.

Requirements

Platforms: .NET Compact Framework

.NET Framework Security:

See Also

SqlCeConnection Class | SqlCeConnection Members | System.Data.SqlServerCe Namespace

Syntax based on .NET Framework version 1.1.
Documentation version 1.1.1.

Send comments on this topic.

© Microsoft Corporation. All rights reserved.