The Repair method attempts to repair a corrupted database.
Unless the destination connection string explicitly specifies a password, the resulting database will be unencrypted, whether or not the source was encrypted. |
This method can also be used to change the case-sensitivity setting of the database. The second code example in the CreateDatabase Method (SQL Server Compact) topic demonstrates how to create a repaired database with a case-sensitive collation. For more information about case-sensitive databases, see Working with Collations (SQL Server Compact).
If you set the CaseSensitive (or ssce:Case Sensitive) connection string property 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. |
object.Repair(SourceConnection, DestinationConnection, RepairOption)
Parameter |
Description |
---|---|
SourceConnection |
A string value specifying a connection to the source database to be repaired. |
DestinationConnection |
A string value specifying the location of the new database file that will be created. |
RepairOption |
Specifies the type of database repair to perform. For more information, see REPAIROPTION. |
Prototype
HRESULT Repair(BSTR SourceConnection, BSTR DestinationConnection, REPAIROPTION RepairOption);
Reference
Concepts
Using and Maintaining Databases (SQL Server Compact)