Search code examples
visual-foxproiis-10adodb-php

Consistent connection failure to vfp


I have been working on an API to run queries on a FoxPro database via PHP (v7.3) using ADODB (v5.20.14). Currently, my working solution uses XAMPP (3.2.2 x86), running on a Windows 2019 server. FoxPro driver (6.01.8629.01).

I'm now trying to get this same setup working using IIS 10, however, I'm running into a strange issue where if I send simultaneous requests to the web server, only the last request will return back data successfully; the issue lies in $db->connect. This is the connect code that I am using:

require_once('adodb/adodb.inc.php');

$db = NewADOConnection("vfp");

$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;

$db->debug = true;
$db->connect("DSN=Visual FoxPro Database;UID=;SourceDB=<UNC PATH>.DBC;SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;") or die("Failed to connect.");

The error that I get back on all but the last request is:

odbc_connect(): SQL error: [Microsoft][ODBC Visual FoxPro Driver]This file is incompatible with the current version of Visual FoxPro.  Run 30UPDATE.PRG to update the file to the current version., SQL state S1000 in SQLConnect

I have found this KB article on the error which seems to suggest that it's an erroneous error; it's misleading.

If you open a database located on a server numerous times from multiple Visual FoxPro 6.0 executables, then the following error randomly appears:

This file is incompatible with the current version of Visual FoxPro. Run 30UPDATE.PRG to update the file to the current version.

This error may also occur if you are opening a Visual FoxPro 6.0 database using ADO or the Visual FoxPro ODBC driver.

I don't believe that this is very helpful as it works when executed via XAMPP, just not IIS. IIS application pools are set to use x86 as ADODB and the FoxPro driver require 32 bit.

I'm not sure what is causing this behavior and why the last request works every time, the connection to the dB is established and data is returned successfully.


Solution

  • Unfortunately, this seems to be an issue with version 6.x of the VFP driver which won't be fixed as VFP was made end of life some years ago; extended support for v9 ended in 2015, you can see the lifecycle here.

    I can't speak for the difference between IIS and XAMPP but they use different underlying technologies.

    Considering the age of VFP, I presume that you're using v6 to support a legacy system? In which case, there's no fix for this issue other than to use a third party xBase driver which supports VFP, there are plenty out there and should work for your existing setup.