Where is the recovery utility SQL Server Compact?

I used C # System.Data.SqlServerCeversion 3.5.1.0 to create a database file .SDF. When opening a connection after creation, I sometimes get the following error:

The database file may be corrupted. Run the recovery utility to check the database file. [Database Name = \? \ C: \ SomeDatabase.sdf]

Where is the repair utility located? How do we use it?

I searched google and stackoverflow for answers:

  • SQL Server Compact Recovery Utility
  • SDF Recovery Utility

This MSDN article article talks about this programmatically. Is there a command line method?

+4
source share
2 answers

#.NET, :

class Program
{
    static void Main(string[] args)
    {
        SqlCeEngine engine = 
             new SqlCeEngine("Data Source = C:\\Users\\SomeUser\\Documents\\SomeDB.sdf");
        if (false == engine.Verify())
        {
            Console.WriteLine("Database is corrupted.");
            try
            {
                engine.Repair(null, RepairOption.DeleteCorruptedRows);
            }
            catch(SqlCeException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        Console.WriteLine("Press any key to continue.");
        Console.ReadLine();
    }
}

MSDN. ScriptCs.

+5

sqlcecmd , sqlcecmd.codeplex.com

+3

Source: https://habr.com/ru/post/1536015/


All Articles