Why is it necessary to target CF when doing SQL Server CE?

Posts   
 
    
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 26-Aug-2009 22:46:26   

I'm confused by this requirement. I can add System.Data.SqlServerCe assembly to my project and talk to a CE database with no problems. But it appears to me that to get LLBLGenPro to use CE, I must target the Compact Framework in my DAL projects. Why is that?

confused

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Aug-2009 05:54:42   

If you are using SqlServer CE Desktop, you must use a non-CF platform:

docs wrote:

To be able to target SqlServer CE Desktop, you first has to create a SqlServer project, similar to what you have to do for CF.NET support. Then, you have to select .NET 2.0 or higher as the target platform at tab 1 on the Generator Configuration dialog. CF.NET 1.0/2.0 or .NET 1.x aren’t supported for SqlServer CE Desktop.

What SQlServer Ce version and LLBLGen version do you have?

David Elizondo | LLBLGen Support Team
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 27-Aug-2009 21:21:12   

3.5 sp1 and LLBLGenPro 2.6.

Ah, I was looking at this:

To start with SqlServerCE, first create the project on a normal SqlServer 7/2000/2005 database, then generate code using that project and by selecting CF.NET 1.0, CF.NET 2.0 or CF.NET 3.5 in the platform combo box.

That's from the section "Compact Framework / Sql CE support" in the preface. But that's just explaining if I really do want to target CF + CE, I should be in "Generated code - Database specific features". OK, thanks.

But I did notice this in the generated file DatabaseAdapter.cs, and this helped throw me off, because it looks like CF has to be targeted to make LLBLGenPro use CE.


#if CF
using System.Data.SqlServerCe;
#else
using System.Data.SqlClient;
#endif

Am I still missing something? How does my DAL know that CE is the target if CF is not #defined?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 28-Aug-2009 11:32:25   

Please read the following paragraph in the same Documentation section "Generated code - Database specific features"

SqlServerCe provider registration It's no longer necessary to reference System.Data.SqlServerCe.dll, however on the machine the application is ran which uses compatibility level 3 or 4, this dll has to be installed as documented in the SqlServer CE Desktop documentation about deployment: via the .msi shipped with SqlServer CE Desktop. If you can’t run this .msi installer, be sure your application’s .config file contains the appropriate provider registration for the DbProviderFactory. (this information is installed in the machine.config file by the .msi installer of SqlServer CE Desktop). More details about this are available in the SqlServer CE Desktop documentation (the 'Books online' documents of SqlServer CE Desktop)

JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 28-Aug-2009 15:31:41   

OK, thanks!