1

I developed an app that read data from VFP free tables and databases, using VBA at Excel 2013 Pro 32 bits. The computer used for develop that app was formatted. After that, I installed Office 2016 Pro Plus 64 bits at the same machine. Visual FoxPro 9.0 SP2 and OLE DB Provider for Visual FoxPro 9.0 SP 2 were installed too.

When I run app again, that issues runtime error 3706. Before formatting, that app open databases and free tables without any problem.

What have I done? Install and uninstall VFP (and service pack 2) and OLE DB Provider.

Why that happens? Am I missing any file during VFP install, or during Office Setup? Am I missing other software? I am using Windows 7 64 Bits Professional SP1.

Thanks in advance for your answer.

UPDATE: This code issues the error

'Example for free table

Sub OpenFreeTableForReading()

Dim cnConnection As ADODB.Connection
Dim rstRecordSet As ADODB.Recordset
Dim strConnection As String, strQuery As String
Dim strErrMessage As String
Dim arrData As Variant
Dim lngX As Long

On Error GoTo ErrSub

'Setting connection object and query string command
strConnection = "Provider=VFPOLEDB.1;DataSource=C:\Path\to\TableToOpen.dbf;"
strQuery = "SELECT * FROM TableToOpen"
Set cnConnection = New ADODB.Connection
cnConnection.ConnectionString = strConnection

'This line issues runtime error 3706
cnConnection.Open

'Retrieved records are kept on an array
Set rstRecordSet = New ADODB.Recordset
With rstRecordSet
.CursorLocation = adUseClient
.LockType = adLockReadOnly
.Open strQuery, cnConnection, adOpenStatic

If Not (rstRecordSet.EOF) Then
 'Disconnect the recordset
 .ActiveConnection = Nothing

 'Get the field count
 lngX = .Fields.Count
 arrData = .GetRows()
Else
 'Recordset is empty; create dummy array record
 ReDim arrData(0, 0)
End If
End With

'Printing data - ommited

CloseAll:
    cnConnection.Close
    Exit Sub
ErrSub:
    strErrMessage = CStr(Err.Number) & " " & Trim(Err.Description)
    MsgBox strErrMessage
    Resume CloseAll
End Sub
1
  • Hello. Please post up your code, it's impossible to say without looking at that.
    – Davy C
    Jul 8, 2016 at 18:24

2 Answers 2

1

VFPOLEDB driver is 32 bits. You cannot use it with 64 bits excel. You may try using Advantage Database Server instead.

PS: An easier solution would be to use code written and compiled in VFP or C# (targeting x86).

1
  • That's right. VFPOLEDB does not work under 64 bits architecture. Thanks for your help. Jul 8, 2016 at 21:47
0

This is a shot in the dark, but if you have declared functions, you'll have to change "public/private declare function/sub" to "public/private declare ptrsafe function/sub" or vice versa. The addition of "ptrsafe" makes 32-bit declared functions/subs compatible on a 64-bit operating system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.