Click to Rate and Give Feedback
MSDN
MSDN Library

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Compact Method
[Note: This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Reclaims wasted space in the SQL Server Everywhere Edition database by creating a new database file from the existing file. This method is also used to change the collating order, encryption, or password settings of the database.

Namespace: System.Data.SqlServerCe
Assembly:   System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

C#
public void Compact (
	string connectionString
)
Visual Basic (Declaration)
Public Sub Compact ( _
	connectionString As String _
)
Visual Basic (Usage)
Dim instance As SqlCeEngine
Dim connectionString As String

instance.Compact(connectionString)
Visual C++
public:
void Compact (
	String^ connectionString
)
JScript
public function Compact (
	connectionString : String
)

Parameters

connectionString
String

The connection string to the destination database.

The connection string specifies a connection to the destination database that will be created by this method.

An exception is thrown if the specified database already exists or if another file with the same name already exists. .

If you pass an empty string for the connection string, the new database file overwrites the old database file and maintains the same name.

The following example demonstrates how to compact a SQL Server Everywhere Edition database.

Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

Reference

SqlCeEngine Class
SqlCeEngine Members
System.Data.SqlServerCe Namespace
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker