HOWTO: Use ADOFILTR.DLL to Transfer Database Tables
ID: Q196034
|
The information in this article applies to:
-
Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0
SUMMARY
This article demonstrates how to use the ADOCE API (the ADOFILTR.DLL
exports) in Visual Basic to programmatically import and export data tables
between the desktop and a remote device.
MORE INFORMATION
ADOFILTR.DLL, Pocket Access file converter and synchronizer, is a part of
the ActiveX Data Objects 2.0 SDK for Windows CE (ADOCE 2.0). It allows
programmatic transfer of database tables between the host desktop computer
and the remote device. It runs on the desktop computer, not the remote
device. The desktop initiates and controls the transfer process. For
additional information on ADOCE 2.0, please see the following article in
the Microsoft Knowledge Base:
Q192531 INFO: Overview of ActiveX Data Objects SDK for Windows CE
The sample code provided below transfers a table in the Biblio.mdb sample
database between the desktop and the remote device. Before trying this
sample, you need to make sure that ADOCE 2.0 is already installed on the
remote device.
Modify Biblio.MDB
Referential integrity rules may interfere with table import. Therefore, the
Biblio database must be modified to have a table without relationships. You
can use the Visual Data Manager add-in in Visual Basic to modify
Biblio.MDB and create a new table.
- In the Visual Data Manager, open Biblio.MDB.
- In the SQL window, insert and execute the following SQL statement:
SELECT Authors.* INTO Authors2 FROM Authors WHERE (Authors.AU_id < 50)
This will create a new table called "Authors2" with the data from the
original Authors table.
Create the Project to Import and Export Tables
- In Visual Basic, create a new standard EXE project. Form1 is generated by default.
- Add a CommandButton (Command1) to Form1. Set the caption property to
"Device to PC."
- Add a second CommandButton (Command2) to Form1. Set the caption property to "PC to Device."
- Add the following code to the declarations section of the form module:
Private 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
Private Declare Function DEVICETODESKTOP _
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
- Add the following code to the Click event procedure of Command1:
Dim result As Long, sPath As String, sTableList As String
spath = "c:\Program Files\DevStudio\VB\biblio.mdb"
sTableList = "Authors2.."
' Change mouse pointer to hourglass.
Screen.MousePointer = vbHourglass
' import table from remote device.
result = DEVICETODESKTOP( sPath, sTableList, False, False, "")
' Return mouse pointer to normal.
Screen.MousePointer = vbDefault
If result = 0 Then
MsgBox "Transfer Successful"
Else
MsgBox "An error occurred transferring the data: " & result
End If
- Add the following code to the Click event procedure of Command2:
Dim result As Long, sPath As String, sTableList As String
spath = "c:\Program Files\DevStudio\VB\biblio.mdb"
sTableList = "Authors2.."
' Change mouse pointer to hourglass.
Screen.MousePointer = vbHourglass
'Export table to remote device.
result = DESKTOPTODEVICE(sPath, sTableList, False, False, "")
' Return mouse pointer to normal.
Screen.MousePointer = vbDefault
If result = 0 Then
MsgBox "Transfer Successful"
Else
MsgBox "An error occurred transferring the data: " & result
End If NOTE: The paths given in the declaration and procedures are for default
Installations; modify them according to your system.
Errors that may occur (not an exhaustive list):
-2147024894 The remote device may not be connected properly, or ADOCE
1.0 was not installed or registered correctly on the
remote device. To install ADOCE 1.0 on the remote device,
you need to click on Start, Programs, Microsoft ADOCE 1.0
and then Install ADOCE on HPC while the device is
connected to the desktop machine and communication is OK.
-2146824447 The destination table may already exist on the desktop and
Overwrite was set to False, or Overwrite was set to True
but the table is not allowed to be overwritten. A log file
may also display.
-2147217865 This error may occur if an attempt is made to import a
table does not exist from the remote device.
NOTE: The values above are the result of subtracting the vbObjectError constant from the raw error value.
REFERENCES
Microsoft Windows CE ActiveX Data Objects SDK 2.0 Help
Additional query words:
wce adoce dao ado wince vbce vbce5 vbce6
Keywords : kbADO kbAPI kbDatabase kbToolkit kbVBp kbVBp500 kbVBp600 kbWinCE kbGrpVB
Version : WINDOWS:5.0,6.0
Platform : WINDOWS
Issue type : kbhowto
|