Tuesday, March 27, 2012

Advice on developing a mobile app that uses SQL 2005 CE

Hi,

I am new to SQL 2005 CE but fairly experienced with SQL 2000 and know my way around SQL 2005. I am creating a PDA app that must support the following scenario:

My company has a SQL 2000 server with a "computer assets" database. This asset database must be able to be transferred to an .sdf file (SQL 2005 mobile) on the PDA when the user docks their PDA to the desktop PC (not the same machine as the SQL 2000 server). This transfer can be via an option in the mobile app that is initiated by the user, or automatic.

The mobile application basically supports stock-taking of the assets, so users go out on site and record information about the assets. This information is stored in a separate .sdf database on the PDA.

When the user gets back to the office they dock with their desktop and then must transfer the data from the second .sdf database onto the SQL 200 server. Lets call this the "asset metadata".

thats basically it! but im having issues finding the right process to attack the data transfer tasks.

My issues:

- Firstly, how do i populate the .sdf on the PDA for development purposes? Microsoft tutorials seem to be geared at SQL server 2005 management

studio only. I only have SQL server 2005 Management Studio Express on

my development machine as well as all the necessary SQL 2005 CE SDKs and VS2005. We

do not use SQL Server 2005 at my organisation as yet and it will be some time before we migrate across. In effect im looking for something that behaves like a DTS package to transfer data across.

- How to populate the "asset database" .sdf file from the SQL 2000 server when the user has docked to their desktop PC? (This needs to be refreshed )

- How to transfer the "asset metadata" from the .sdf on the PDA to the SQL server?

ive looked at merge replication a little but am not sure whether this is what i need and again most online information seem to be tailored to SQL Server 2005.

Can anyone kindly point me in the right direction?

I believe that merge replication will be the solution to your problems, as it will allow you to: Populate the device SDF, but for development and production purposes, and transfer inserted data from the device to the central SQL Server.

I would strongly recommend upgrading to SQL Server 2005, but SQL Server 2000 is a supported platform for merge synchronization with SQL 2005 CE.

The topics below this covers both SQL Server 2000 and 2005 configurations: http://msdn2.microsoft.com/en-us/library/ms171850.aspx

|||Hi Erik,

Thanks for your post. This article does indeed look like what i was searching for. ive been a bit busy on other work though and unable to dive into it thoroughly.

i will update once i have time to get back to the SQL mobile project again.|||


Hello again,


ive managed to setup everything as follows:

- created the publication for merge replication on the sql 2000 server.
- allowed the publication to have sql server CE subscrptions
- snapshot was created fine (at least sql server said everything was successful/)
- set up IIS for replication and this also went well. IIS is running
on the same physical server as SQL 2000

So i then added some code to the applicaiton on my pocket PC, and it seems to be working except that the database on the local device doesnt seem to get any data added to it.

The following VB.Net code is what i am using (i have replaced server names etc with arbitrary values enclosed in < > for privacy reasons)

Try
' Set the Replication object.
repl = New SqlCeReplication()
repl.InternetUrl = "http://<myserver>/AssetSync/sqlcesa30.dll"
repl.Publisher = "<publisher name>"
repl.PublisherDatabase = "AssetRegister"
repl.PublisherLogin = "<login>"
repl.PublisherPassword = "<password>"
repl.Publication = "asset_list"
repl.SubscriberConnectionString = "Data Source=\Assets.sdf"
repl.Subscriber = "MySubscriber"

' Create the Local SSCE Database subscription.
repl.AddSubscription(AddOption.ExistingDatabase)

' Synchronize to the instance of SQL Server 2000 to populate the Subscription.
repl.Synchronize()

Catch ex As SqlCeException
' Use your own error handling routine to show error information.
outputLabel.Text = ex.ToString

Finally
outputLabel.Text = "Subscription Complete!"
' Dispose of the Replication object.
repl.Dispose()
End Try

There are no erros thrown and my application actually outputs "Subscription Complete!" .. but the database is not being populated. My VS2005 project has a blank Assets.sdf file in it.

i have also tried starting the app with no .sdf file and changing the subscription code to "repl.AddSubscription(AddOption.CreateDatabase)"

i am thinking there might be something wrong with the publication? but this behvaes the same - no database created.
|||

I would start by testing the publication from a desktop, namely via SQL Server 2005 management studio, or using this utility from Nick Randolph: http://www.softteq.com/tools/publish.htm

No comments:

Post a Comment