This is a migrated thread and some comments may be shown as answers.

Problem in using SQL CE 4.0

2 Answers 138 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mercede
Top achievements
Rank 2
Mercede asked on 27 Oct 2012, 03:36 PM
Hello, 

I'm trying to use SQL CE 4.0 with OpenAccess ORM for a website project. 
My environment is Windows 2008 R2 (64x) / Visual Studio 2012 Professional. 

Here is the code that I try to use: 

using (DB.SQLCEContext E = new DB.SQLCEContext(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
           {
               DB.Site s = new DB.Site();
               s.IsActive = true;
               s.Title = "Nescorp";
 
               E.Add(s);
               E.SaveChanges();
           }

But at E.Add I always get an exception

"System.NotSupportedException: SQL Server Compact is not intended for ASP.NET development.\r\n   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver.connect(ConnectionString connectionString, IDictionary driverProps, ConnectionPoolType poolType, LogEventStore pes)\r\n   at OpenAccessRuntime.Relational.sql.SqlDriver.InitializeFor(ConnectionString connectionString, Boolean noConnect, PropertySet props, DBDriver& driver, Connection& conn, ConnectionPoolType poolType)\r\n   at OpenAccessRuntime.Relational.RelationalStorageManagerFactory..ctor(StorageManagerFactoryBuilder b)\r\n   at OpenAccessRuntime.storagemanager.StorageManagerFactoryBuilder.createSmfForURL()"}

I'm using the latest version of OpenAccess. What am I doing wrong?

2 Answers, 1 is accepted

Sort by
0
Mercede
Top achievements
Rank 2
answered on 27 Oct 2012, 03:42 PM
I added the following line in Global.asax

AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);


and then the exception changed to the following:

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:\Projects\Website\App_Data\Contents.sdf ] Telerik.OpenAccess.RT.sql.SQLException: 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:\Projects\Website\App_Data\Contents.sdf ]


   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver.connect(ConnectionString connectionString, IDictionary driverProps, ConnectionPoolType poolType, LogEventStore pes)


   at OpenAccessRuntime.Relational.sql.SqlDriver.InitializeFor(ConnectionString connectionString, Boolean noConnect, PropertySet props, DBDriver& driver, Connection& conn, ConnectionPoolType poolType)
0
Accepted
Ady
Telerik team
answered on 30 Oct 2012, 05:14 PM
Hi Mercede,

 Have you specified the appropriate provider name in the connection string? For SQL Ce 4.0 it should be
providerName="System.Data.SqlServerCe.4.0"

Please check the connection string in the config file.

Do get back in case you need further assistance.

Kind regards,
Ady
the Telerik team
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Tags
Data Access Free Edition
Asked by
Mercede
Top achievements
Rank 2
Answers by
Mercede
Top achievements
Rank 2
Ady
Telerik team
Share this question
or