SqlCeEngine.Repair Method

Repairs a corrupted database.

Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)

Syntax

'Declaration
Public Sub Repair ( _
    connectionString As String, _
    options As RepairOption _
)
'Usage
Dim instance As SqlCeEngine
Dim connectionString As String
Dim options As RepairOption

instance.Repair(connectionString, options)
public void Repair (
    string connectionString,
    RepairOption options
)
public:
void Repair (
    String^ connectionString, 
    RepairOption options
)
public void Repair (
    String connectionString, 
    RepairOption options
)
public function Repair (
    connectionString : String, 
    options : RepairOption
)

Parameters

  • connectionString
    The local connection string to the database.
  • options
    The RepairOption to use when repairing the database.

Remarks

If the repair method is invoked by using the RepairOption's DeleteCorruptedRows value, all corrupted pages are discarded from the database. This may result in significant data loss, but the data recovered using this option should be free from corruption.

If the repair method is invoked by using the RepairOption's RecoverCorruptedRows value, the database will attempt to read data from the corrupted pages. This potentially results in more data being recovered, but this option does not guarantee that the data recovered will be free of corruption.

Example

Dim engine As New SqlCeEngine("Data Source = AdventureWorks.sdf")

' Specify null destination connection string for in-place repair
'
engine.Repair(Nothing, RepairOption.DeleteCorruptedRows)
SqlCeEngine engine = new SqlCeEngine("Data Source = AdventureWorks.sdf");

// Specify null destination connection string for in-place repair
//
engine.Repair(null, RepairOption.DeleteCorruptedRows);

.NET Framework Security

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Platforms

Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows XP Professional x64 Edition, Windows XP SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

Version Information

.NET Compact Framework

Supported in: 2.0

See Also

Reference

SqlCeEngine Class
SqlCeEngine Members
System.Data.SqlServerCe Namespace