开发者

SQL Server CE Enterprise Library 5 Cannot pass parameters

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜