I am using php to update some tables under VFP 9.0 using ADO COM.
I am able to select and update the DBF until i specify any Where clause.
The moment i add a where clause to the query, it simply returns or updates 0 rows.
$conn = new COM("ADODB.Connection");
$conn->Open('Provider=VFPOLEDB.1;Data Source="C:\\testDB.dbc";');
$query = "UPDATE TABLE1 set COL1 = \"AA\", COL2 = \"Updated value\" ";
$conn->Execute($query);
$query = "SELECT * FROM TABLE1 ";
$rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
while (!$rs->EOF) {
echo " Got COL1: " . $rs->Fields("COL1") . " :: COL2: " . $rs->Fields("COL2") . " id: " . $rs->Fields("ID") . "\n";
$rs->MoveNext();
}
Result:
Got COL1: AA :: COL2: Updated value id: 0
Got COL1: AA :: COL2: Updated value id: 1
Got COL1: AA :: COL2: Updated value id: 2
Code 2: With Where clause
$query = "UPDATE TABLE1 set COL1 = \"BB\", COL2 = \"NEW2\" WHERE ID = 1";
$conn->Execute($query);
$query = "SELECT * FROM TABLE1 ";
$rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
while (!$rs->EOF) {
echo " Got COL1: " . $rs->Fields("COL1") . " :: COL2: " . $rs->Fields("COL2") . " id: " . $rs->Fields("ID") . "\n";
$rs->MoveNext();
}
Result:
Got COL1: AA :: COL2: Updated value id: 0
Got COL1: AA :: COL2: Updated value id: 1
Got COL1: AA :: COL2: Updated value id: 2
The ID column is the key in the above table.
I am relatively new to VFP. I am not sure if this a Visual Foxpro setting or something else which prevents the updates or select if done selectively.