Help!!! How to generate code for Sql CE 3.5

Posts   
 
    
lucheya
User
Posts: 1
Joined: 18-Sep-2008
# Posted on: 18-Sep-2008 08:24:28   

We are developing a desktop application with the SQL Server Compact Edition 3.5 Desktop database. I have been unsuccesful in my attempts to generate code that works for this project. I haven't been able to find clear and streamlined instructions about how to accomplish this.

I would appreciate it if someone can help outline all the step that I need to take to make sure this is done correctly or point me in the direction of robust documentation on this subject.

Here's my configuration so far:

Created the database in Sql Server 2005. During the code generation process, I select C# as the target language, .net 3.5 as the target platform and the template group as "Adapter". Two database project generated - DatabaseGeneric, DatabaseSpecific. They compiled without errors. In my example console program, I changed the connection string to target the Compact Edition database which was copied from Sql Server as follows:


<appSettings>
        <add key="Main.ConnectionString" value="Data Source=C:\projects\CE.sdf"/>
</appSettings>

..and my test code to see if I can write a record to the CE database succesfully.....



            LogEventModuleEntity logEventModuleEntity = new LogEventModuleEntity();
            logEventModuleEntity.LogEventModuleId = Guid.NewGuid();
            logEventModuleEntity.LogEventModuleName = "Test Module";
            logEventModuleEntity.LogEventModuleDescription = "Test Description";
            logEventModuleEntity.CreatedByUserId = Constants.SystemUserId;
            logEventModuleEntity.ModifiedByUserId = Constants.SystemUserId;
            logEventModuleEntity.CreatedDate = DateTime.Now;
            logEventModuleEntity.ModifiedDate = DateTime.Now;

            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.SaveEntity(logEventModuleEntity);
            }


this is the error that I get when I run the console program....

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

cry

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Sep-2008 09:05:06   

Hi lucheya,

You are very close I think. You have to specify the compatibility level for the DQE at .config, to signal it that it has to generate queries for SqlServer CE.

<add key="SqlServerDQECompatibilityLevel" value="4" />

Check these instructions about SQLServer CE Desktop Support.

David Elizondo | LLBLGen Support Team