SQL Server Compact 3.5

Posts   
 
    
Oberon
User
Posts: 5
Joined: 01-Apr-2008
# Posted on: 02-Apr-2008 10:25:28   

I'm currently testing the LLBLGen Pro v2.5 Demo (4 Feb 2008 ) I'm developing an application for a Windows CE device with CF 2.0.

I created a little project with LLBLGen Pro v2.5. I am able to get data from the database if i use VS2005 - SQL Server Compact 3.0.

Now i have done the exact same thing for VS2008 - SQL Server Compact 3.5 but this ain't working. Now I get an InvalidCastException on "adapter.FetchEntityCollection(customers, filter)"

The test code:


        Dim filter As New RelationPredicateBucket(StraatFields.StrtPostcode = "8020")
        Dim customers As New EntityCollection(Of StraatEntity)()
        ' fetch them using a DataAccessAdapter instance
        Using adapter As New DataAccessAdapter("data source=\Program Files\PDADL\Q2C.sdf", True)
            adapter.FetchEntityCollection(customers, filter)
        End Using

        For Each c As StraatEntity In customers
            MsgBox(c.StrtStraat & " - " & c.StrtPostcode & " - " & c.StrtGemeente)
        Next

Anyone can help me out?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Apr-2008 11:01:19   

Would you please post the complete exception text with the stack trace? Also check the generated SQL code.

Now i have done the exact same thing for VS2008 - SQL Server Compact 3.5

Would you please explain what do you mean by the "exact same thing"?

Did you follow the following steps explained in the manual?

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 or CF.NET 2.0 in the platform combo box. It's recommended, if possible, you use SqlServer CE 3.0 (SqlMobile) as you can create the database in SqlServer CE 3.0 from an existing SqlServer 2005 database using replication functionality in SqlServer 2005.

Oberon
User
Posts: 5
Joined: 01-Apr-2008
# Posted on: 02-Apr-2008 11:30:38   
"at System.Data.SqlServerCe.SqlCeCommand.set_DbConnection() at System.Data.Common.DbCommand.System.Data.IDbCommand.set_Connection() at SD.LLBLGen.Pro.ORMSupportClasses.Query..ctor() at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery..ctor() at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ() at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreatePagingSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection() at PDADL.Form1.Form1_Load() at System.Windows.Forms.Form.OnLoad() at System.Windows.Forms.Form._SetVisibleNotify() at System.Windows.Forms.Control.set_Visible() at System.Windows.Forms.Application.Run() at PDADL.Form1.Main() "

Well i made a project (VS2005 - SQL CE 3.0) and followed that step from the manual and this worked fine. Then i made another project in the same way but used VS2008 and SQL CE 3.5 instead. When i tried the program it gave me the error.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Apr-2008 11:31:55   

Would you please post the complete exception text and the stack trace?

Oberon
User
Posts: 5
Joined: 01-Apr-2008
# Posted on: 02-Apr-2008 11:40:15   

Exception: "System.InvalidCastException: InvalidCastException at System.Data.SqlServerCe.SqlCeCommand.set_DbConnection() at System.Data.Common.DbCommand.System.Data.IDbCommand.set_Connection() at SD.LLBLGen.Pro.ORMSupportClasses.Query..ctor() at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery..ctor() at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ() at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreatePagingSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection() at PDADL.Form1.Form1_Load() at System.Windows.Forms.Form.OnLoad() at System.Windows.Forms.Form._SetVisibleNotify() at System.Windows.Forms.Control.set_Visible() at System.Windows.Forms.Application.Run() at PDADL.Form1.Main() "

Stacktrace: at System.Data.SqlServerCe.SqlCeCommand.set_DbConnection() at System.Data.Common.DbCommand.System.Data.IDbCommand.set_Connection() at SD.LLBLGen.Pro.ORMSupportClasses.Query..ctor() at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery..ctor() at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ() at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreatePagingSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateSelectDQ() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection() at PDADL.Form1.Form1_Load() at System.Windows.Forms.Form.OnLoad() at System.Windows.Forms.Form._SetVisibleNotify() at System.Windows.Forms.Control.set_Visible() at System.Windows.Forms.Application.Run() at PDADL.Form1.Main()

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Apr-2008 12:09:44   

Would you please try to use an absolute path for the database file, as follows:

Using adapter As New DataAccessAdapter("data source=C:\Q2C.sdf;", True) { ... }

Also, you should be using SD.LLBLGen.Pro.DQE.SqlServerCE.NET20.dll for SQLServer CE Desktop (.NET 2.0) or SD.LLBLGen.Pro.DQE.SqlServerCE.CF20.dll on the compact framework

Oberon
User
Posts: 5
Joined: 01-Apr-2008
# Posted on: 02-Apr-2008 12:13:57   

I'm developing for a mobile device so the path is correct. (In the V2005 project it worked fine) SD.LLBLGen.Pro.DQE.SqlServerCE.CF20.dll is included

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Apr-2008 12:35:15   

As the manual says:

When loading the generated VS.NET projects, the references to the SqlServerCE DQE for .NET 2.0 should be checked as well as the reference to the SqlServerCE client dll shipped with the SqlServer CE SDK. If they're not correct, please correct the references.

I guess it has something to with the System.data.sqlserverce.dll (most probably a version mismatch).

As the SD.LLBLGen.Pro.DQE.SqlServerCE.CF20.dll was built against System.data.sqlserverce.dll v.3.1 which is used by VS 2005. While VS 2008 uses System.data.sqlserverce.dll v.3.5

So I think you might need to re-build the SD.LLBLGen.Pro.DQE.SqlServerCE.CF20.dll against v.3.5 of the System.data.sqlserverce.dll.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39861
Joined: 17-Aug-2003
# Posted on: 02-Apr-2008 13:48:07   

You indeed need an assembly redirect, and I'm not sure if compact framework even supports that (probably not).

There are more problems at the moment with CE 3.5, as our DQE generates anonymous parameters in the queries, but 3.5's parameter binding engine is broken in some queries.

We will address this soon, in v2.6, though at the moment you're out of luck and you've to use SqlServerCe v3.1 instead of 3.5.

We officially don't support CF.NET 3.5 yet. It depends on how easy we get our code working on cf.net if we'll support it at all in the future or if we'll abandone cf.net altogether.

Frans Bouma | Lead developer LLBLGen Pro
Oberon
User
Posts: 5
Joined: 01-Apr-2008
# Posted on: 02-Apr-2008 13:50:23   

Ok, i'll try it out. Thanks for the reply's and hopefully i don't have to wait until the 2.6 wink