Problem in using SQL CE 4.0

3 posts, 1 answers
  1. Mercede
    Mercede avatar
    9 posts
    Member since:
    Dec 2008

    Posted 27 Oct 2012 Link to this post

    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. Mercede
    Mercede avatar
    9 posts
    Member since:
    Dec 2008

    Posted 27 Oct 2012 Link to this post

    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)
  3. DevCraft banner
  4. Answer
    Ady
    Admin
    Ady avatar
    589 posts

    Posted 30 Oct 2012 Link to this post

    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.
Back to Top