LITTLEBLACKDOG.COM Forum Index LITTLEBLACKDOG.COM

 
LWD LWD   FAQ FAQ   Memberlist Memberlist   Usergroups Usergroups   Active Topics Active Topics   Register Register  
  Profile Profile   Log in to check your private messages Log in to check your private messages   Log in Log in  
  Who is Online Who is Online   Image Gallery Image Gallery   Chat Chat   Search Search  
  LWDGear       LBDGear  

View next topic
View previous topic
Post new topic     Reply to topic   LITTLEBLACKDOG.COM Forum Index » Code Warriors
Author Message
Alphi
Big Dog
Big Dog


Joined: 05 Apr 2002
Age: 38
Posts: 3129
Location: Grand Rapids, MI USA

Post Posted: Tue Mar 24, 2009 5:12 am   Post subject: Sync SQLCE db on a WinCE handheld with a MySQL db (web) Reply with quote Back to top  

Hey guys,

I need your help with a little development project I'm doing on the side.


Essentially, I'm creating a WindowsCE application (using VB.NET 2003) for a handheld barcode scanner. I won't go into the gruesome details about the application itself, but just the details pertaining to my question.

The handheld application contains a database (coded in SQlServerCE). We also have a database on a web server (MySQL - but only reachable by PHP code on that server).

We also have a desktop that is hooked (all the time) to the handheld cradle/dock (via a serial port - the handheld does not support wireless).


Long story short: I need to code a way to synchronize the MySQL database on the web server with the database on the device, when it's on the cradle.



Originally my thoughts were these:
1) I'll already have a thick-client app on the desktop for maintaining the data on MySQL - I can include the sync code there too, since that's more likely to be able to see both databases than the handheld would
2) I have a PHP developer coding some basic web service methods to query (just pass the connection string & SQL, get XML back) and update (again pass just connection string & SQL), and I'm sure I won't have any problem getting/updating the data from the thick-client application on the desktop


Here's the problem: getting the data to the handheld.


My first thought was that I'd see if I could just transfer the entire SQL CE database file from the handheld (it shouldn't be terribly big), then sync the two, and then upload it back (overwriting the old one).

But I cannot figure out how to transfer files back and forth from this thing.


Of course, if I could find a way to read/write data on the handheld from the thick-client, then I wouldn't even have to worry about transferring files.


Any ideas/suggestions?

_________________
They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.
- Benjamin Franklin
View user's profile Send private message Send e-mail ICQ Number
anglachel
Guide Dog
Guide Dog


Joined: 08 Nov 2003
Posts: 9123
Location: MN

Post Posted: Tue Mar 24, 2009 10:25 am   Post subject: Reply with quote Back to top  

are you building this "sync" into the desktop, or into the hand held?

when connected via active sync you should have access to the the same internet the PC has access too.

if your going from the desktop, there are all kinds of insteresting bits including is the database in use, or locked when the hand held is docked...

_________________

Quidquid latine dictum sit, altum sonatur.
Death to Shuttleworth!
View user's profile Send private message AIM Address
gregw
Tail-Wagger
Tail-Wagger


Joined: 25 May 2003
Posts: 2854
Location: About 2000 miles south of where I want to be.

Post Posted: Tue Mar 24, 2009 10:39 am   Post subject: Reply with quote Back to top  

I don't have a solution for you, but I'm interested in doing something similar, so please post your solutions if you get one.

I'm probably going to use SQLite though for my handheld DB and then sync to MySQL.

_________________
Some people are like slinkys... not really good for anything but they still bring a smile to your face when you push them down a flight of stairs.
View user's profile Send private message
Alphi
Big Dog
Big Dog


Joined: 05 Apr 2002
Age: 38
Posts: 3129
Location: Grand Rapids, MI USA

Post Posted: Wed Mar 25, 2009 5:01 am   Post subject: Reply with quote Back to top  

anglachel wrote:
are you building this "sync" into the desktop, or into the hand held?

when connected via active sync you should have access to the the same internet the PC has access too.

if your going from the desktop, there are all kinds of insteresting bits including is the database in use, or locked when the hand held is docked...


Both - there could be changes on the web server database and there could be changes on the handheld... I need to merge all changes so that both handheld and web databases have the exact same data.

_________________
They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.
- Benjamin Franklin
View user's profile Send private message Send e-mail ICQ Number
anglachel
Guide Dog
Guide Dog


Joined: 08 Nov 2003
Posts: 9123
Location: MN

Post Posted: Wed Mar 25, 2009 3:51 pm   Post subject: Reply with quote Back to top  

at work they use some sofware from sybase "mobilink" to sync from handhelds to oracle servers, though I'm guessing it will work with mssql too...

_________________

Quidquid latine dictum sit, altum sonatur.
Death to Shuttleworth!
View user's profile Send private message AIM Address
Lycander
Lead Dog
Lead Dog


Joined: 24 May 2002
Age: 26
Posts: 12370
Location: The Constitution State

Post Posted: Wed Mar 25, 2009 5:00 pm   Post subject: Reply with quote Back to top  

http://support.microsoft.com/kb/301091

The above article talks about importing tables from an Access or ODBC database on the desktop to ADOCE on the WinCE device. For ODBC, on the desktop first create an ODBC datasource that connects to the MySQL database. Follow the second set of instructions for ODBC in that article, you'd use that newly created datasource during import.

If you want to be able to have basic file read/write from a desktop thick client to the filesystem on the WinCE device that's possible too. Back in the day when I was doing WinCE programming, the SDK included a library (.lib + .dll) to interface with ActiveSync. I don't work there anymore and all the knowledge is on my work PC so I'm doing this from memory. Basically your desktop thick client would link to a DLL library provided in the platform SDK. This exposes a lot of functionality that ActiveSync has, including the ability to access the device filesystem. So as long as you have the device connected and ActiveSync running, first you call a function to Connect to the device, that starts the session. From there you have at your disposal the basic create/open/delete functions.

Check the documentation in the platform SDK and programming against ActiveSync. I haven't done any development since MS made the move to Visual Studio only. I've only used the free eMbedded Visual Tools when it was still available.
View user's profile Send private message
Alphi
Big Dog
Big Dog


Joined: 05 Apr 2002
Age: 38
Posts: 3129
Location: Grand Rapids, MI USA

Post Posted: Mon Mar 30, 2009 7:12 am   Post subject: Reply with quote Back to top  

Just so you guys know, the solution I'm implementing to resolve my problem is this:

Since we have a MySQL database that can only be directly accessed from PHP, we set up basic PHP Web Services on the web server - to do things like ExecuteNonQuery (returning "done" or an error) or ExecuteQuery (which returns XML for the data table returned or an error).


Then in my handheld code, I have logic to simply call the web service to get the data as needed (I'm writing the sync logic right now). If it can't find the web service, I'm assuming that the handheld isn't on the cradle, and that it shouldn't be doing a sync.

_________________
They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.
- Benjamin Franklin
View user's profile Send private message Send e-mail ICQ Number
Display posts from previous:   
Post new topic     Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
phpBB SEO
All times are GMT - 8 Hours

Help us keep advertisements off this site. Donate today!