Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP read a paradox db gives errors

Status
Not open for further replies.

scriggs

IS-IT--Management
Jun 1, 2004
286
GB
I am trying to link to a 3rd party paradox database and have adapted some MS SQL ODBC code. The paradox database is called IB01.db:

Code:
	function GetODBCLink()
	{   
    $i = 0;
    $files = "";

// odbc_query.php
$odbc_dsn = "sagedata_paradox";
$odbc_userid = "";
$odbc_password = "9PL";

//$query = "SELECT IB01.ClientCode, IB01.ReportName FROM IB01.DB WHERE IB01.ClientCode Not Like 'ZZ%' ORDER BY IB01.ClientCode";
$query = "SELECT ClientCode, ReportName FROM IB01.DB";

if(!($odbc_db = odbc_connect($odbc_dsn, $odbc_userid, $odbc_password)))
	die ("Could not connect ot ODBC data source $odbc_dsn");
  
if(!($odbc_rs = odbc_do($odbc_db, $query)))
	die("Error executing query $query");
  
$num_cols = odbc_num_fields($odbc_rs);
if($num_cols < 1) die("Query returned an empty set");

    while(odbc_fetch_row($odbc_rs))
    {
//	$files[$i] = array('ClientKey' => odbc_result($odbc_rs,'ClientKey'),'CoyName' => odbc_result($odbc_rs,'CoyName'));
//	$files[$i] = odbc_result($odbc_rs,'ClientKey');
	$files[$i] = odbc_result($odbc_rs,'ClientCode') . " | " . odbc_result($odbc_rs,'ReportName');
	$i++;
    }
    return $files;
  }

But I get the error:

Warning: odbc_do(): SQL error: [Microsoft][ODBC Paradox Driver] The Microsoft Jet database engine could not find the object 'IB01.DB'. Make sure the object exists and that you spell its name and the path name correctly., SQL state S0002 in SQLExecDirect in E:\WASP\scripts\files.inc.php on line 225
Error executing query SELECT ClientCode, ReportName FROM IB01.DB

I think this could be my query, as I had other errors originally which I have solved. Any help?
 
It sounds to me like your ODBC DSN, sagedata_paradox, is not set up correctly. The Paradox file to which it points either does not exist, or there is a permission problem somewhere.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thx, I have setup the DSN to the directory which contains IB01.db (as well as lots of other .db files). I have also set the network directory to the same location. I don't have any other options to change.

Anyway I can check if the DSN is working? Also, do you know if my query looks OK, its quite diff to an MS query?
 
When you are setting up the DSN in the Control Panel applet, there might be a "test settings" button somewhere. I can't be sure, as I haven't messed with Paradox in a long time.


A SELECT query, if kept simple, is usually pretty portable. But again, I haven't messed with Paradox files in a long time. One thing that I find interesting...a SELECT query takes in its FROM clause the name of a table, not the name of a database file.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top