Article ID: 814850 - Last Review: May 16, 2007 - Revision: 4.6 Compacting a SQL Server 2000 CE 2.0 database or a SQL Server 2005 Compact Edition database by using Visual Basic .NETOn This PageSUMMARYThis article contains a sample program that was developed in
Microsoft Visual Basic .NET for compacting a Microsoft SQL Server 2000 Windows
CE Edition (SQL Server CE) 2.0 database file or a Microsoft SQL Server 2005 Compact Edition database file. The sample program, CompactDB.exe,
uses the SqlCeEngine.Compact method to compact the SQL Server CE database. You can use
CompactDB.exe to compact a SQL Server CE or SQL Server Compact Edition database in suspect mode.
MORE INFORMATIONThe internal structure of a database may fragment over time
and after much use, resulting in a waste of disk space. If the fragmentation is
excessive, performance may deteriorate. To avoid fragmentation and to get
better performance, you can compact the database. You can compact a SQL Server CE database or a SQL Server Compact Edition database by using SQL Server CE Query Analyzer. To do so, select the database, and then click the Compact and Repair icon. However, you cannot compact a database in suspect mode by using SQL Server CE Query Analyzer, because the suspect database may not be displayed under Databases in the Objects tab. In such a case, you can use CompactDB.exe to compact the database. During the compact process, CompactDB.exe creates a destination file named Comp_Temp.sdf. If the database is compacted successfully, the source database file is deleted and the destination database file is renamed to the deleted source file name. Before you compact the database, make sure that:
Set a Unique Device Name for Pocket PC Emulator
Upload the Database File to Pocket PC EmulatorBefore you run CompactDB.exe, you must upload the SQL Server CE database file that you want to compact in the Pocket PC Emulator. To copy the database file from your computer to the Pocket PC Emulator, in the Pocket PC Emulator follow these steps:
Compact the SQL Server CE DatabaseTo compact a database by using CompactDB.exe, follow these steps:
REFERENCES
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
306452
(http://support.microsoft.com/kb/306452/
)
FIX: SQL Server CE eMbedded Visual Basic CompactDatabase unable to fix corrupted database
For more information about compacting SQL
Server CE databases, visit the following Microsoft Web site:http://msdn2.microsoft.com/en-us/library/aa225644(SQL.80).aspx
(http://msdn2.microsoft.com/en-us/library/aa225644(SQL.80).aspx)
APPLIES TO
| Article Translations
|
Back to the top
