Repairs a corrupted database.
Public Sub Repair ( _ connectionString As String, _ options As RepairOption _ )
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 )
There are 4 values of RepairOption that can be used to repair the corrupted database:
RecoverAllPossibleRows
RecoverAllOrFail
DeleteCorruptedRows
RecoverCorruptedRows: This option is deprecated, as it does not ensure that the recovered data is free from corruption. You should use RecoverAllOrFail.
In SQL Server Compact 4.0, 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
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);