0
votes

I am trying to open a .sdf file (SQL Server Compact) from my C# WinForm program and I get this error:

{Incompatible Database Version. If this was a compatible file, run repair. For other cases refer to documentation. [ Db version = 4000000,Requested version = 3505053,File name = \?\C:\inetpub\wwwroot\WS\bin\PC.sdf ]}

I need to have the possibility to open version 4 and 3.5

How to do it?

Thanks

1

1 Answers

0
votes

You need to have both versions of the SQL Server CE deployed to your application directory: http://robindotnet.wordpress.com/2010/02/28/how-to-deploy-the-sqlserver-compact-edition-software-locally/

You will need to reload the assembly reference for SQL Server CE 3.5 and 4.0 using code like this:

Assembly assembly = Assembly.LoadFrom("sqlcecompact35.dll");
Type type = assembly.GetType("SomeType");
object instanceOfSomeType = Activator.CreateInstance(type);

Correct me if I'm wrong, but I believe that if you open a version 3.5 database in version 4.0, it will be upgraded and you will not be able to open it using the version 3.5 provider again. This is just from personal experience.