Search code examples
phpvisual-foxpro

Writing to a VFP Database using the Visual FoxPro OLE DB Provider in PHP


I am having trouble writing to a VFP database in php using visual fox pro OLE DB Provider (vfpoledb.dll). I have no problem accessing the data with select statements as described and answered in this question:

Php, odbc & vfp

However when it comes to writing I am having trouble receving a

Cannot update the cursor ''tablename'', since it is read-only.

I thought the solution to this problem was to include Mode="ReadWrite" (have tried Share Exclusive also) in the Open command as described in the msn article, as such :

$conn = new COM("ADODB.Connection");
$conn->Open('Provider="VFPOLEDB.1";Data Source="' . $filename . '";Mode="ReadWrite";');

However I still receive the same error when executing a statement such as:

$up = $conn->Execute("UPDATE tablename SET fieldname='Testing' WHERE fieldname = 'somevalue'");

Any ideas, is it even possible?
Anyone else love wrapping legacy systems?


Solution

  • Is this table part of a VFP database? Have you checked the file properties of the .DBF or the .DBC to see if they are read-only? This error typically means that the DBF or index(CDX or IDX) are marked as read-only.

    Or, you might have performed a SELECT * FROM TABLE INTO CURSOR MyCURSOR which would make the cursor MyCURSOR read-only. In this case, you would want to add the READWRITE clause to the SELECT statement.