Search code examples
phpodbcpervasive-sql

Connecting to Peachtree database using php?


Iam developing an application in php which can fetch transaction,invoices.etc from peachtree database. So for database access I selected ODBC method by connecting using Pervasive SQL. I used connection string like this:-

$connection = odbc_connect("DRIVER={Pervasive ODBC Engine Interface};Dbq=C:\Sagepro\Peachtree\Company\Sample\PAW\BCS","Peachtree","password");

But it is giving error

 ( ! ) Warning: odbc_connect() [function.odbc-connect]: SQL error: [Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine Interface][Data Record Manager]Cannot locate the named database you specified(Btrieve Error 2301), SQL state S1000 in SQLConnect in C:\wamp\www\peachtreeapi\index.php on line 2

How to rectify this??


Solution

  • Use this connection string.. it will work

     $connect=odbc_connect("Driver={Pervasive ODBC Engine Interface};ServerName=localhost;ServerDSN=DSNname;","Username","Password",SQL_CUR_USE_ODBC);