开发者

Provider: System.Data.SqlServerCe.3.5 is not installed

Hi I am trying to use LINQ with SQL Server CE. I generated the dmbl file with SqlMetal, added it to the project, and also added a reference to assembly System.Data.SqlServerCe.dl开发者_JS百科l

My app is WPF based on .NET4.0 and is built as x86.

On my PC SQL Server CE is installed.

I tried the following code:

const string connStr = @"Spiri_SQL_CE_DB.sdf";
var dataContext = new Spiri_SQL_CE_DB(connStr);
var testNicks = dataContext.TestNick;

But I get this error:

Cannot open 'C:\Users\Jan\Documents\Visual Studio 2010\Projects\C#\Pokec_Messenger_Project\Pokec_Messenger\DB_TEST\Spiri_SQL_CE_DB.sdf'. Provider 'System.Data.SqlServerCe.3.5' not installed.

What am I missing? A reference to some assembly, or something else?

IF I RETARGET APP ON .NET3.5 IT WORKS GOOD !


You need Microsoft SQL Server Compact 3.5, see here for download links: http://www.microsoft.com/sqlserver/2005/en/us/compact.aspx

Usually, this database just works with x-copy deployment, so once you've installed it on your dev machine, you can just copy it over your work environment directory.


This solution worked for me just fine, all you need is to pass a SQLCE Connection object instead of connecion string:

const string connStr = @"Spiri_SQL_CE_DB.sdf";
var conn = new System.Data.SqlServerCe.SqlCeConnection(connStr);
var dataContext = new Spiri_SQL_CE_DB(conn);
var testNicks = dataContext.TestNick;


If you are running the app on a 64 bit windows. Except for installing Microsoft SQL Server Compact 3.5, you have to force the app to be x86 CPU only by change the platform target to x86 in build configuration which is inside the property of the project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜