Tuesday, August 01, 2006

The Undocumented CopyDB Method

Current verisons of the Srego CE ToolPack ActiveX control have an undocumented method. This method is not in the documentation because it did not meet the expectations of the users who wanted it added; however, many may find it useful none the less. The CopyDB method is an equivalent to the Srego CE ToolPack Command-Line tool ceCopyDB. The problem most users found with this method is that once you start it coping a .cdb file to the desktop from the device or an .mdb from the desktop to the device, it doesn't return control to your application until it is finished. So, there is no progress reporting, cancelling, or doing something else while it copies.


long CopyDB(long mode, BSTR sourceFile, BSTR destFile, BSTR options);

  • mode - set to 0 for copy from desktop to device; 1 for device to desktop.
  • sourceFile and destFile - the appropriate filename on the desktop or device.
  • Options - this is a string of option identical to the ceDbCopy.exe. The exception is that you do not use the /D2P, /P2D, /D, or /P flags as they are already specified with the other parameters.

[/SY] Keep tables in sync
[/T table name] Specific table to copy, this option is repeatable
[/O] Allow overwrite

To use the options, you just string them together with a space between the different options:
“/T tab1 /T tab2”

You will have to experiment with this to see what works and what doesn’t.

Example:

Private Sub Command1_Click()
' Copy Desktop to Device
MousePointer = vbHourglass
If SregoCETPx1.CopyDB(0, "c:\temp\test33.mdb", _
"\my documents\test.cdb", "") Then
List1.AddItem "Successfully copied."
Else
temp = SregoCETPx1.GetErrorMessage
While temp <> ""
List1.AddItem temp
temp = SregoCETPx1.GetErrorMessage
Wend
End If
MousePointer = vbDefault
End Sub

Private Sub Command2_Click()
' Copy Device to Desktop
MousePointer = vbHourglass
If SregoCETPx1.CopyDB(1, "\my documents\test.cdb", _
"c:\temp\test1.mdb", "") Then
List1.AddItem "Successfully copied."
Else
temp = SregoCETPx1.GetErrorMessage
While temp <> ""
List1.AddItem temp
temp = SregoCETPx1.GetErrorMessage
Wend
End If
End Sub

No comments: