Search code examples
c#sql-server-ce

How to repair SQLServerCE Database programmatically


How can I repair SQLServerCE Database from C# code. I am using this call:

engine.Repair(GetDBConnectionString(), RepairOption.RecoverAllOrFail);

where GetDBConnectionString() is a private function that builds Connection String for me. But this raises exception: "The file that is being referenced is not a SQL Server Compact database file format"

Regards, Pawel


Solution

  • You are using the wrong ADO.NET version in your own app. I think you may get this error if you use version 3.5.1 against a 4.0 database