I can't seem to get my existing 3.1 sdf file upgraded to 3.5. I don't have Orcas installed, so I went with the SqlCeEngine.Upgrade() API method instead:

SqlCeEngine engine = new SqlCeEngine(ConnectionString);


The bad news is that I get the following error when executing that code:

failed: System.Data.SqlServerCe.SqlCeException : There is a file sharing violation. A different process might be using the file. [ C:\moonlite\TaxApp\Tests\ServiceTests\bin\Debug\taxjet.sdf ]

at System.Data.SqlServerCe.SqlCeEngine.ProcessResults(IntPtr pError, Int32 hr)

at System.Data.SqlServerCe.SqlCeEngine.Repair(SEFIXOPTION option, String dstConnStr, RepairOption repairOption)

at System.Data.SqlServerCe.SqlCeEngine.Upgrade(String destConnectionString)

It doesn't matter whether I pass a new database connection string to the Upgrade() method or not.

Is this part not ready Is there another way I can get this working



Re: Upgrade to 3.5 format


Has your app closed all connections to the database you would like to upgrade

What does your connection string look like

Re: Upgrade to 3.5 format


Yes, my app has closed the one connection it had to the database. I've even tried running outside of the IDE. I can't figure out what has that sdf open (if anything).

The ConnectionString looks like this:

string.Format("DataSource=\"{0}\"; Password='{1}'", DB_FILENAME, DB_PASSWORD);

It is the same connection string as the one I can successfully connect to the sdf with.

Are you saying you've had the Upgrade() API work for you

Re: Upgrade to 3.5 format


I can't even call Engine.Upgrade (making a reference to the Desktop 3.5 Dll installed globally). Is your app a device or desktop app Have you tried without password (compact first to a file without password in 3.1, the upgrade with 3.5)

Re: Upgrade to 3.5 format


Thanks for the reply. The app is a desktop app. I tried without the password and it worked. I'll try to dig some more to see if there's a real bug here, or if it was something I did.

Re: Upgrade to 3.5 format

Devesh Anand [MSFT]


I had tried the original scenario (Upgarding a SSC31 database with password) and it worked for me.

Did you check that SSC31 database that you wanted to upgarded was not opened or connected by VS2005 in server explorer

The code that I wrote to validate the scenario is



SqlCeEngine eng = new SqlCeEngine(@"DataSource='C:\Northwind31Password.sdf'; Password='abcxyz'");


SqlCeConnection conn = new SqlCeConnection(@"DataSource=C:\Nextdatabase.sdf");

// Inplace Upgarde


//SqlCeConnection conn = new SqlCeConnection(@"DataSource='C:\Northwind31Password.sdf'; Password='abcxyz'");


catch (Exception ex)




Devesh Anand

Re: Upgrade to 3.5 format


I have a couple of questions to help you figure out why it worked when you did not specify the password:

1.Before calling upgrade, did you also call compact, as Eric had suggested

2.Is the original 3.1 db file password protected or not

There are a few things that you should note when doing compact/upgrade/repair with password protected db files:

1. If the source db file has password, and during upgrade, you do not specify a password in the destination string, then the resulting db will still be having the same password.

2. If the source db file has password, and during compact/repair , you do not specify a password in the destination string, then the resulting db file will loose its password protection.

If you still do not figure out why it worked when you did not specify the password, then let me know.