tags:

views:

338

answers:

4

I am looking for a code snippet/library to read data from third party foxpro DB over the Net using php/Java from a Linux server. Is there any library available? Some people seem to be using Dbase library for php? Does that work?

What parameters do i need from the Foxpro DB other than the default (databasename, username, password). DBF name, connection string ??

A: 

You might want to tell us what version of FoxPro the data is created by. FoxPro for DOS tables are different from Visual FoxPro tables if they are contained in the database container (DBC).

The DOS tables might be accessible using DBase tools as they did have some compatibility.

Here is a link to an example of accessing Visual FoxPro data. It should also work with FoxPro for DOS data.

http://social.msdn.microsoft.com/Forums/en/visualfoxprogeneral/thread/821a3cb7-2f25-4cc9-b3a6-ec4551013d2a

Rick Schummer

Rick Schummer
The version is VFP 6.0
With VFP 6 databases you can use the ODBC driver if the connector technology you settle on uses ODBC. Free ODBC driver is found here:http://msdn.microsoft.com/en-us/vfoxpro/bb190232.aspx
Rick Schummer
A: 

Best way I have found is with MSSQL server setup as a linked server into the Foxpro database. MSSQL is on the same machine as foxpro. Queries go to the MSSQL server. I use the free one. I likely had the same problem you are dealing with...getting current Foxpro data across a network.

Lee Bethune
+1  A: 

XBaseJ might be what you are looking for. It's open source and it's quite good - I use it in several applications where the customers still hang on their 15 year old FoxPro applications.

A. Ionescu
A: 

A while back, i was researching for the same solution and hit many dead ends. i wanted a solution which worked with php though.
Some of them which i tried were
1. Xbase drivers: They worked well for simple DBFs, but then they do not support the newer data types like DateTime fields, so that option was ruled out.
2. VFP ODBC Driver : This works well if you are working on older VFP version since the development on this one has stopped and it does not support the newer autoincrement fields and you keep getting strange errors like "Not a table" which drives you complete crazy. "VFP ODBC Driver doesnt support Tables with autoincrement fields"
3. Commercial tools: There are many other commercial options which obviously wont work for me
4. Free Tools(DBF to CSV) which convert the DBF to a csv or similar, but then this will work if you are doing only select. You cant do any updates.

The last option which finally worked for me was: Visual Foxpro OLE Driver.

You could install the OLE Driver from here. Sample code looks like

$conn = new COM("ADODB.Connection");
$conn->Open('Provider=VFPOLEDB.1;Data Source="C:\\testDB.dbc";'); 

$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();
}

$query = "UPDATE TABLE1 set COL1 = \"AA\", COL2 = \"Updated value\" ";
$conn->Execute($query);

I did not find any documentation for php but you could refer to MSDN ADO API and use similar API especially if you want to do transaction based operations.

$conn->BeginTrans();
..
..
$conn->CommitTrans();
or 
$conn->RollbackTrans();
mtanish