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
)
member Repair : 
        connectionString:string * 
        options:RepairOption -> unit 
public function Repair(
    connectionString : String, 
    options : RepairOption
)

Parameters

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.

Note

Starting with (SP1), you can use this method to create a repaired database with a case-sensitive collation. If you set the connection string property CaseSensitive to false in the Repair method, for a case sensitive database, if the database contains a case sensitive index, the loss of case sensitivity can cause an index error in the repair log even though the code runs successfully. The error occurs when two unique records are treated as equal. Two example values are 'aaa' and 'aaA'. The following message is written to the repair log file: Failed to create index

Examples

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);

See Also

Reference

SqlCeEngine Class

SqlCeEngine Members

System.Data.SqlServerCe Namespace