DesktopToDevice

DesktopToDevice enables programmatic control over the conversion of .mdb files to ADOCE tables.

Syntax

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

Parameters

DesktopLocn

Specifies the file name and path of the .mdb file to be transferred, or the Data Source Name (DSN) if ODBC support is enabled.

TableList

Specifies the list of tables and fields that is converted and copied to the device. The following code example shows the form for TableList .

[!]tablename[<period>fieldname]<period><period>[[!]tablename[<period>fieldname]<period><period>]

A leading exclamation mark (!) marks this table as read-only on the device. If this is a zero-length string ("") or if the parameter is not provided, 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, table names do not need to be delimited. Delimited field or table names are not supported.

Sync

Optional. If True, enables ActiveSync. False disables active sync. This parameter is not available in ADOCE 1.0 or 2.0.

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

Optional. Specifies the .cdb file that tables are copied to on the device. Not supported in ADOCE 1.0 or 2.0.

Remarks

The behavior of DesktopToDevice 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 appear, showing the transfer status. An error return does not cause the log file to automatically display. Instead, an error value, HRESULT, is returned by the function. The calling application can then take appropriate action.

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"