B
Beebs
OK, I'm in desperation mode here. I have a vb .NET CF app that uses
Peter's InTheHand for ADOCE cdb databases. I put together a sync app
in VB 6 that utilizes RAPI and everything worked great, until I
password protected the Access desktop database, now when I execute
this line:
intRetVal = DESKTOPTODEVICE(desktopPath, "", False, True, devicePath)
I get what I assume is the ODBC login box that asks for a username and
password. All desktopPath parameter is is just that, a variable which
holds the path, not anything else, so why should I need to have the
password anywhere, and if I do, where...can anyone help me. Below is
my code:
Private Sub btnSync_Click()
'On Error GoTo ErrHandler
Dim intRetVal As Long
Dim lngFileHandle As Long
Dim typFindFileData As CE_FIND_DATA
Dim desktopPath As String
Dim replacementPath As String
Dim devicePath As String
Dim DesktopDB As Database
Dim DeviceDB As Database
Dim unid As Long
Dim rstFormative1
Dim rstFormative2
desktopPath = "C:\Program Files\EES\EES.mdb"
replacementPath = "C:\Program Files\EES\Sync\EES.mdb"
devicePath = "\Program Files\EES\EES.cdb"
Screen.MousePointer = 11
lblStatus.Caption = "Backing up desktop database"
Me.Refresh
If zFile_Exists(replacementPath) = False Then
FileCopy desktopPath, replacementPath
'Delete existing EES.mdb file
Kill desktopPath
End If
'Move data from A--> B
lblStatus.Caption = "Downloading data from Pocket PC"
Me.Refresh
'Transfer the tables from the handheld
intRetVal = DEVICETODESKTOP(desktopPath, "", False, False,
devicePath)
If intRetVal <> 0 Then
'MsgBox "Error " & intRetVal & " Occurred."
FileCopy replacementPath, desktopPath
'Delete existing EES.mdb file
Kill replacementPath
MsgBox "An error occurred transferring EES's data. Please
verify the connection to your handheld and that the EES handheld
application is closed and try again.", vbCritical, "Synchronization
Error"
Screen.MousePointer = 0
Exit Sub
End If
Me.Refresh
lblStatus.Caption = "Processing Data"
Me.Refresh
'Merge data to EES.mdb copy
Set DesktopDB = OpenDatabase("C:\Program Files\EES\Sync\EES.mdb",
False, False, ";pwd=EES2005")
Set DeviceDB = OpenDatabase("C:\Program Files\EES\EES.mdb", False,
False)
Set rstFormative1 = DeviceDB.OpenRecordset("SELECT * FROM
FormativeReview")
If Not rstFormative1.EOF And Not rstFormative1.BOF Then
rstFormative1.MoveFirst
While Not rstFormative1.EOF
unid = rstFormative1("Appraisal")
Set rstFormative2 = DesktopDB.OpenRecordset("SELECT * FROM
FormativeReview WHERE Appraisal = " & unid)
If Not rstFormative2.EOF And Not rstFormative2.BOF Then
'Record already exists
Else
rstFormative2.AddNew
rstFormative2("UniqueID") = rstFormative1("Appraisal")
rstFormative2("Comments1") =
rstFormative1("Comments1")
rstFormative2("Comments1_rate") =
rstFormative1("Comments1_rate")
rstFormative2("Comments2") =
rstFormative1("Comments2")
rstFormative2("Comments2_rate") =
rstFormative1("Comments2_rate")
rstFormative2.Update
End If
rstFormative1.MoveNext
Wend
rstFormative1.Close
rstFormative2.Close
End If
DeviceDB.Close
DesktopDB.Close
lblStatus.Caption = "Restoring desktop database"
Me.Refresh
FileCopy replacementPath, desktopPath
'Delete existing EES.mdb file
Kill replacementPath
lblStatus.Caption = "Clearing Pocket PC data."
Me.Refresh
'Delete the file from the handheld
intRetVal = CeRapiInit() 'Initialize RAPI
If intRetVal <> INIT_SUCCESS Then
MsgBox "Error with the initialization of RAPI with the PDA: "
& CeGetLastError
CeRapiUninit
Exit Sub
End If
'Examines whether file on the PDA even exists
lngFileHandle = CeFindFirstFile(devicePath, typFindFileData)
If lngFileHandle <> INVALID_HANDLE Then
'There that acts now is not no more needed, since we know,
file is...
CeFindClose lngFileHandle
'Delete file
lngFileHandle = CeDeleteFile(devicePath)
If lngFileHandle = INVALID_HANDLE Then
MsgBox "Error with the deletion of the file: " &
devicePath
Exit Sub
End If
End If
lblStatus.Caption = "Uploading data to Pocket PC."
Me.Refresh
'Copy the updated database to the handheld
intRetVal = DESKTOPTODEVICE(desktopPath, "", False, True,
devicePath)
If intRetVal <> 0 Then
MsgBox "An error occurred transferring EES's data to the
handheld. Please verify the connection to your handheld and try
again.", vbCritical, "Synchronization Error"
Screen.MousePointer = 0
'Exit Sub
End If
Screen.MousePointer = 0
lblStatus.Caption = "Synchronization Complete!"
Me.Refresh
End Sub
Peter's InTheHand for ADOCE cdb databases. I put together a sync app
in VB 6 that utilizes RAPI and everything worked great, until I
password protected the Access desktop database, now when I execute
this line:
intRetVal = DESKTOPTODEVICE(desktopPath, "", False, True, devicePath)
I get what I assume is the ODBC login box that asks for a username and
password. All desktopPath parameter is is just that, a variable which
holds the path, not anything else, so why should I need to have the
password anywhere, and if I do, where...can anyone help me. Below is
my code:
Private Sub btnSync_Click()
'On Error GoTo ErrHandler
Dim intRetVal As Long
Dim lngFileHandle As Long
Dim typFindFileData As CE_FIND_DATA
Dim desktopPath As String
Dim replacementPath As String
Dim devicePath As String
Dim DesktopDB As Database
Dim DeviceDB As Database
Dim unid As Long
Dim rstFormative1
Dim rstFormative2
desktopPath = "C:\Program Files\EES\EES.mdb"
replacementPath = "C:\Program Files\EES\Sync\EES.mdb"
devicePath = "\Program Files\EES\EES.cdb"
Screen.MousePointer = 11
lblStatus.Caption = "Backing up desktop database"
Me.Refresh
If zFile_Exists(replacementPath) = False Then
FileCopy desktopPath, replacementPath
'Delete existing EES.mdb file
Kill desktopPath
End If
'Move data from A--> B
lblStatus.Caption = "Downloading data from Pocket PC"
Me.Refresh
'Transfer the tables from the handheld
intRetVal = DEVICETODESKTOP(desktopPath, "", False, False,
devicePath)
If intRetVal <> 0 Then
'MsgBox "Error " & intRetVal & " Occurred."
FileCopy replacementPath, desktopPath
'Delete existing EES.mdb file
Kill replacementPath
MsgBox "An error occurred transferring EES's data. Please
verify the connection to your handheld and that the EES handheld
application is closed and try again.", vbCritical, "Synchronization
Error"
Screen.MousePointer = 0
Exit Sub
End If
Me.Refresh
lblStatus.Caption = "Processing Data"
Me.Refresh
'Merge data to EES.mdb copy
Set DesktopDB = OpenDatabase("C:\Program Files\EES\Sync\EES.mdb",
False, False, ";pwd=EES2005")
Set DeviceDB = OpenDatabase("C:\Program Files\EES\EES.mdb", False,
False)
Set rstFormative1 = DeviceDB.OpenRecordset("SELECT * FROM
FormativeReview")
If Not rstFormative1.EOF And Not rstFormative1.BOF Then
rstFormative1.MoveFirst
While Not rstFormative1.EOF
unid = rstFormative1("Appraisal")
Set rstFormative2 = DesktopDB.OpenRecordset("SELECT * FROM
FormativeReview WHERE Appraisal = " & unid)
If Not rstFormative2.EOF And Not rstFormative2.BOF Then
'Record already exists
Else
rstFormative2.AddNew
rstFormative2("UniqueID") = rstFormative1("Appraisal")
rstFormative2("Comments1") =
rstFormative1("Comments1")
rstFormative2("Comments1_rate") =
rstFormative1("Comments1_rate")
rstFormative2("Comments2") =
rstFormative1("Comments2")
rstFormative2("Comments2_rate") =
rstFormative1("Comments2_rate")
rstFormative2.Update
End If
rstFormative1.MoveNext
Wend
rstFormative1.Close
rstFormative2.Close
End If
DeviceDB.Close
DesktopDB.Close
lblStatus.Caption = "Restoring desktop database"
Me.Refresh
FileCopy replacementPath, desktopPath
'Delete existing EES.mdb file
Kill replacementPath
lblStatus.Caption = "Clearing Pocket PC data."
Me.Refresh
'Delete the file from the handheld
intRetVal = CeRapiInit() 'Initialize RAPI
If intRetVal <> INIT_SUCCESS Then
MsgBox "Error with the initialization of RAPI with the PDA: "
& CeGetLastError
CeRapiUninit
Exit Sub
End If
'Examines whether file on the PDA even exists
lngFileHandle = CeFindFirstFile(devicePath, typFindFileData)
If lngFileHandle <> INVALID_HANDLE Then
'There that acts now is not no more needed, since we know,
file is...
CeFindClose lngFileHandle
'Delete file
lngFileHandle = CeDeleteFile(devicePath)
If lngFileHandle = INVALID_HANDLE Then
MsgBox "Error with the deletion of the file: " &
devicePath
Exit Sub
End If
End If
lblStatus.Caption = "Uploading data to Pocket PC."
Me.Refresh
'Copy the updated database to the handheld
intRetVal = DESKTOPTODEVICE(desktopPath, "", False, True,
devicePath)
If intRetVal <> 0 Then
MsgBox "An error occurred transferring EES's data to the
handheld. Please verify the connection to your handheld and try
again.", vbCritical, "Synchronization Error"
Screen.MousePointer = 0
'Exit Sub
End If
Screen.MousePointer = 0
lblStatus.Caption = "Synchronization Complete!"
Me.Refresh
End Sub