DEVBUZZ Homepage Retrieving Device Data from the Desktop with SQLink
 
Web www.devbuzz.com
  HOME PAGE
  All Articles
  Advertise
  Consulting

 Development
  Discuss - Forums
  Still in the box?
  .Compact Framework
  Code Snippets
  SQL Server CE
  Database
  MS Resources
 Stores
  Developer Controls
  Pocket PC Hardware
  Pocket PC Software
  Pocket PC Books
  .NET CF Books
  Book Reviews
  SPB SW Discounts
  RESCO SW Discounts
 DEVBUZZ Info
  About Us
  Help
  Join our email list
  Links & Ratings
  Press & Comments
  Pocket PC version
  Software Reviews
  Hardware Reviews
 Authors
  Authors
  Article Guide
  Competitions
 Resources
  Developers
  Register
  Login

  SPB Discounts!
 Columnists
  Rick Winscot
 Past Blast
  Personal Media Ctr
  Gizmobility
  eVB Legacy
  Old news
  Hosted Software
  Wireless
  Newsletters
  Carl Davis
  Upton Au

 Pocket PC Registry
  Join the registry
  View current list
 Current Poll
Are you converting to .NET Compact Framework?
Yes, it has changed my life!
No, I'm sticking with eVB
.NET CF what's that`?

Current results
3431 votes so far
 Recent Forum Threads [goto forums]

Get Computername
read... (67 hits)


Great aid to development productivity
read... (82 hits)


ThreadingTimer sample code
read... (143 hits)


Multithreading with .NET CF
read... (194 hits)


Moving from eMbedded Visual Basic to Visual Basic .NET
read... (166 hits)


.NET Compact Framework 2.0 Service Pack 2
read... (226 hits)


Transfer Data from SQL Server 2000 to SQL Server Compact Edition
read... (298 hits)


This protocol version is not supported
read... (236 hits)


Converting Lowercase to uppercase wont work
read... (203 hits)


Direct access to MS SQL Server 2000
read... (374 hits)


Creating SDF file in Desktop
read... (513 hits)


Winsock in CF.NET
read... (316 hits)


Using Pocket Outlook to submit HTML page form with MAILTO action
read... (420 hits)


Missing file "System.Data.PocketPC.asmmeta.dll"
read... (268 hits)


HP iPAQ hw6915 Serial Port Issue
read... (309 hits)


Info on the recent forum changes
read... (341 hits)


SqlServer tools from Redgate
read... (383 hits)


Arrow keys and Hardware navigation button
read... (393 hits)


O2 XDA lls pin sync cable to comport
read... (322 hits)


Creating dynamic folders on Pocket PC OS
read... (299 hits)

Custom Windows Mobile software development.
LBS Challenge 2007
LBS Challenge Eight previous NAVTEQ Global LBS Challenge® participants have received venture capital funding and nine past LBS Challenge winners have launched commercial applications on major wireless carriers. Register your non-commercial LBS application in the 2007 NAVTEQ Global LBS Challenge in one of three regions: Americas, Europe-Middle East-Africa (EMEA) or Asia-Pacific(APAC). You could win a share of $2 million in prizes. This could be your year.
Dream. Develop. Win.

Development | Starting Out

Retrieving Device Data from the Desktop with SQLink
Written by Christopher Tacke  [author's bio]  [read 37419 times]
Edited by Derek

Download the code   Discuss this article   eVB Ver 3.0   

Page 1  Page 2 

Introduction

About a year ago we started development on an enterprise application for a customer that had several Pocket PC devices that were used for data collection in the field. The idea was that an administrator could assign certain "jobs" to a user through a PC interface and push those jobs to the user's device. The user would then collect field data and when they were done at the end of the day, the data would be extracted from the devices and put into a central database.

The customer wanted the data access to be driven not from the device, but from the desktop. They wanted menu items like "Send Jobs to Device", "Get Completed Jobs From Device"" and "Delete Finished Jobs On Device". While this seemed like a simple task, we couldn't find any tools to do it.

We dismissed ActiveSync as an option because we wanted to be able to scale the application to SQL Server as well as provide direct interfacing in the PC application. We looked at SQL Server for CE, but there was no way to initiate a data transfer from the PC. We also looked at a couple popular commercial applications. These again required device-side action plus they had a per-user or per-device pricing and we were trying to provide a fixed-cost solution that the client could scale to their desire and need without having to purchase licenses.

We finally came to the conclusion that we were going to have to write our own data transfer engine and so was born the concept of SQLink. SQLink is not a synchronization engine, and it never was intended to be one. It doesn't compare say an Access database and a CDB on the device and determine what is different about the two. Instead SQLink gives the desktop programmer the ability to directly run SQL commands in PC applications against Pocket PC device databases.

Architecture

SQLink consists of two pieces: a device-side executable (SQLink.exe) and a PC side Active-X library (SQLink.dll). The general architecture follows this outline:

  • The PC applications (Server) creates a SQLink object.
  • The Server connects to the Pocket PC device (Client).
  • The client launches the silent SQLink executable, which calls back to the Server.
  • The Server can now pass SQL statements to the Client and the Client can pass back data.
  • The returned data is put into a Recordset object on the Server
  • A notification event fires to let the PC application know the data is ready.

Using SQLink

Simplicity was one of our requirements for SQLink and the end-product shows it. Still, it is important to know that SQLink operates in a non-blocking, or asynchronous, manner. This means that when you run a SQL statement, the Server application does not wait for the data to return from the Client before it continues processing. Instead, an event fires when the data is ready and at that point the Server can use the data in Recordset format. This requires a little more thought in architecting a Server application, but it allows large datasets to be transferred through slow connections (like a serial port) without causing the Server application to appear "locked" to the user.

The easiest way to understand how SQLink works is through a sample project. Download the SQLink sample project from http://www.innovativedss.com/sqlink.asp for this walk through.

The SQLink library has a single object called Link. It is through the Link that all SQLink data transfer occurs, so the first thing the project does is create a Link object:

Private Sub Form_Load()
Set obj = New SQLink.Link
'init code for command list
End Sub

Form_Load also contains some initialization code that fills the Command ListBox to make things a bit easier to work with by allowing us to select pre-written commands instead of having to type them in. By double-tapping an item in the list, txtSend get automatically populated.

Connecting to the Device

Once the object has been created, the next step is to Connect to the device. This connection is made via ActiveSync so the device must be connected to the PC via ActiveSync, though it doesn't matter whether the connection is serial, USB, or TCP/IP. To connect, simply call the Connect method of the Link object. cmdConnect Click shows how to do this:

Private Sub cmdConnect_Click()
If txtPort <> "" Then
' use user-defined port
obj.Connect txtHost, CInt(txtPort)
Else
' use default port (4377)
obj.Connect txtHost
End If
End Sub

Next Page 

Back to Starting Out | [Article Index]

 

Back to the top of the page.
Chris De Herrera's Windows CE Website Windows CE News & Information Source
Copyright ©2000-2007 by DEVBUZZ.COM, Inc., NJ. USA.MSDEVELOP