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.
DESKTOPTODEVICE (DesktopLocn, TableList, Sync, Overwrite, DeviceLocn)
[!]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.
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"