简体   繁体   English

打开SQL Server CE版本3.5和4

[英]Open SQL Server CE version 3.5 and 4

I am trying to open a .sdf file (SQL Server Compact) from my C# WinForm program and I get this error: 我试图从我的C#WinForm程序中打开.sdf文件(SQL Server Compact),但出现此错误:

{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 ]} [Db版本= 4000000,请求版本= 3505053,文件名= \\?\\ C:\\ inetpub \\ wwwroot \\ WS \\ bin \\ PC.sdf]}

I need to have the possibility to open version 4 and 3.5 我需要打开版本4和3.5

How to do it? 怎么做?

Thanks 谢谢

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/ 您需要将两个版本的SQL Server CE都部署到您的应用程序目录中: 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: 您将需要使用以下代码重新加载SQL Server CE 3.5和4.0的程序集引用:

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. 如果我错了,请纠正我,但是我相信,如果您在4.0版中打开3.5版数据库,则该数据库将被升级,并且您将无法再次使用3.5版提供程序来打开它。 This is just from personal experience. 这仅仅是根据个人经验。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM