开发者

SQL Server CE Enterprise Library 5 Cannot pass parameters

开发者 https://www.devze.com 2023-04-10 10:44 出处:网络
I have an SQL CE(.sdf) database which I am trying to access from MVC3 application using MS Enterprise Library 5.0. I have referenced the SQLCE dll for Compact Edition 4.0.

I have an SQL CE(.sdf) database which I am trying to access from MVC3 application using MS Enterprise Library 5.0. I have referenced the SQLCE dll for Compact Edition 4.0. I use the following code to execute a simple Select using Enterprise Library

>   SqlCeDatabase objDB = new SqlCeDatabase(connectionString);

>   IDa开发者_StackOverflowtaReader rdr = objDB.ExecuteReaderSql("select *
>              from sys_config where (cfg_code>=@p1 and cfg_code<=@p2) or
>                                     cfg_code=@p3",
>                                     new DbParameter[] { new SqlCeParameter("@p1",
>                         1010), new SqlCeParameter("@p2", 1010), new SqlCeParameter("@p3",
>                           1010) });

When I run the above I get the error

The SqlCeParameterCollection only accepts non-null SqlCeParameter type objects, not SqlCeParameter objects

I could not make much sense out of it so I tried to construct an SQLCeCommand using the Select statement and add the same parameter array to the command and executereADER on the command.This seems to work perfectly.

However I want to get it going using Enterprise Library. What am I doing wrong?

thanks

0

精彩评论

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

关注公众号