DesktopToDevice

DesktopToDevice enables programmatic control over the conversion of .mdb files to ADOCE tables. Its behavior parallels that of the Import from Database to Mobile Device dialog box, except that the user-choice dialog boxes do not appear. All progress bars do appear, showing the transfer status. An error return does not cause the log file to automatically display. Instead, an error value, which is HRESULT, is returned by the function. The calling application then can take appropriate action.

Syntax

DESKTOPTODEVICE (DesktopLocn, TableList, Sync, Overwrite, DeviceLocn)

Parameters

DesktopLocn
Specifies the file name and path of the .mdb file to be transferred, or the DSN name if ODBC support is enabled.
TableList
Specifies the list of tables and fields that is converted and copied to the device. It takes the following form:
[!]tablename[<period>fieldname]<period><period>[[!]tablename[<period>fieldname]<period><period>]

A leading “!” marks this table as read-only on the device. If this is a zero-length string ("") or if the parameter is not provided, then the default copying of all tables and appropriate fields is performed. If a table is requested but no field list is provided, then the default fields are copied.

The following code example shows how to copy the Employees table as read-only, how to copy the Product ID and Product Name fields from the Products table, and how to copy the Order ID field from the Orders table.

!Employees..Products.Product ID.Product Name..Orders.Order ID..

The simplest form of TableList is

Employees..

This code example shows how to copy the entire Employees table to the device and enable it to be updated.

Because neither a period (.) nor an exclamation mark (!) are valid in field or table names, there is no need to delimit table names. Delimited field or table names are not supported.

Sync
Optional. Always False. Provided for future compatibility.
Overwrite
Optional. Setting this parameter to True overwrites tables with the same name on the device. Setting this parameter to False generates new table names. True is the default.
DeviceLocn
Provided for future compatibility. Always a zero-length string (""). Database tables are copied to the object store on the H/PC.

Example

The following code example shows a simple Visual Basic application that copies a subset of the Northwind database to the device with no synchronization, but overwriting any existing Northwind tables. The Employees table is sent as a read-only table, while the Products table can be updated.

Declare Function DESKTOPTODEVICE Lib "c:\program files\windows ce services\adofiltr.dll" _
(ByVal desktoplocn As String, _
        ByVal tablelist As String, _
        ByVal sync As Boolean, _
        ByVal overwrite As Integer, _
ByVal devicelocn As String) As Long

result = DESKTOPTODEVICE("c:\mydbs\nwind.mdb", _
"!Employees..Products.ID.Name.Quantity..", False, True, "")
If result <> 0 Then MsgBox "An error occurred transferring the data"