For data storage in the. NET campact Framework Common SQL CE databases, SQL CE is a file database with an extension of *.sdf, once named SQL Server for Windows CE and SQL Server Mobile editio N, the latest version is named SQL Server Compact Edition, in the article unified called SQL CE. This article mainly describes the SQL CE 3.0 and SQL CE 3.5 compatibility issues.
The. NET campact Framework develops SQL CE unified use System.Data.SqlServerCe.dll, which encapsulates namespaces and classes that are consistent, so program code is uniform. However, because the *.SDF data file format is not the same, MS provides a different version of System.Data.SqlServerCe.dll, and its related components are stored in the same location.
Under VS2005 development defaults to the Cf.net version of 2.0, while the default use of the SQL CE version is 3.0. Generally in the following directory C:\Program Files\Microsoft Visual Studio 8 \smartdevices\sdk\sql server\mobile\v3.0 or C:\Program files\ Microsoft SQL Server edition\device\mobile\v3.0 Mobile.
Under VS2008, the default version of Cf.net is 3.5, but you can choose 2.0, and the SQL CE version used by default is 3.5. Typically stored in the C:\Program Files\Microsoft SQL Server Compact edition\v3.5\devices\.
SDF data files and System.Data.SqlServerCe.dll are one-to-one binding, 3.5 SDF data files can only use 3.5 of the sqlserverce.dll,3.0 SDF data file can only use 3.0 of the SqlServerCe.dll, incompatible with each other.
If you use 3.0 SqlServerCe.dll to access the 3.5 SDF data file, there are the following exceptions
System.Data.SqlServerCe.SqlCeException : You are trying to access an older version of a SQL Server
Mobile database. If this is a SQL Server CE 1.0 or 2.0 database, run upgrade.exe.
If this is a SQL Server Mobile 3.0 database, run Compact / Repair.
[ Db version = 3505053,Requested version = 3004180,File name = DB\db.sdf ]
at System.Data.SqlServerCe.SqlCeConnection.ProcessResults()
at System.Data.SqlServerCe.SqlCeConnection.Open()
at System.Data.SqlServerCe.SqlCeConnection.Open()