PHP PDO ODBC Connection

we are trying to create a connection to our SQL database through ODBC in PHP.

This is our current script:

$cnx = new PDO("odbc:Driver={EFR};Server=localhost;Port:7004;Database=EFR;Uid=LcLfVJFLTKTCEHRO;Pwd=*********;"); 

The driver works in Qlikview, which also connects to this database.

The driver was actually found by PHP, but we believe that it simply cannot be entered.

PHP returns the following error:

 Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[IM001] SQLDriverConnect: 0 No transaction control system' in C:\Program Files (x86)\EasyPHP-12.1\www\index.php:2 Stack trace: #0 C:\Program Files (x86)\EasyPHP-12.1\www\index.php(2): PDO->__construct('odbc:Driver={EF...') #1 {main} thrown in C:\Program Files (x86)\EasyPHP-12.1\www\index.php on line 2 

We hope that someone will help us deal with this problem.

+4
source share
2 answers

if you already have ODBC installed and have a saved password, you can simply connect to

 $conn = new PDO("odbc:DSN_NAME") 

where DSN_NAME is the actual name of your ODBC data source, whether it be MySQL, SQL Server or DB2.

You can test your connection with the following:

 try{ $conn = new PDO ("odbc:DSN_NAME"); die(json_encode(array('outcome' => true))); } catch(PDOException $ex){ die(json_encode(array('outcome' => false, 'message' => 'Unable to connect'))); } 
+5
source

try adding DSN to the system instead of user

0
source

All Articles