[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Asked

Viewed 1,886 times

1

Good afternoon, you guys!

I’m having a lot of headaches to connect my code to a file .dbf, and found no solution after running the internet for two days in a row...

This is the code on PHP

<?php

$connection = 'odbc:DRIVER={Microsoft dBase Driver (*.dbf)};DefaultDir=C:\;Exclusive=NO';

$pdo = new PDO($connection);

I’ve already set up the data source:

inserir a descrição da imagem aqui inserir a descrição da imagem aqui

I enabled the drivers extension=pdo_odbc and extension=odbc in the php.ini

Once all this is done, by running the algorithm it returns a:

Fatal error: in C: xampp htdocs Darkness action lerdbf.php on line 5

But, when opening the error log of Apache, he shows it:

[Wed Jul 17 17:52:33.530567 2019] [php7:error] [pid 1660:tid 1960] [client ::1:51411] PHP Fatal error: Uncaught Pdoexception: SQLSTATE[IM002] Sqldriverconnect: 0 [Microsoft][ODBC Driver Manager] Name of the n xe3o data source found and no xe3o driver specified in C:xampp htdocs Darkness action lerdbf.php:5 nStack trace: n#0 C: xampp htdocs Darkness action lerdbf.php(5): PDO->__Construct('odbc:DRIVER={Mi...') n#1 {main} n thrown in C: xampp htdocs Darkness action lerdbf.php on line 5

I don’t know if the solution is easy or difficult, but this code works on other machines with the same operating system (Windows 10), same version of Apache and of PHP... I don’t know what else to try.

  • 1

    In the documentation PDO_ODBC is informing that the library php_pdo_odbc.dll shall be empowered to php.ini, as you did, thus allowing PHP to connect to any data bank cataloged as DNS SYSTEM. In the photo to realize that your database is cataloged as user DNS.

  • 1

    Augusto, I did the same procedure to catalog as DSN System, and even so does not work...

  • I who made you extension=pdo_odbc and extension=odbc, but the extension=php_pdo.dll added it in php ini? And checked for php_pdo.dll?

  • Augusto, I researched about this extension because I don’t have it here, and I saw that I should have come by default with PHP... I can’t find a reliable source to download this dll for PHP version 7.3.7... Know a source?

  • I do not recommend this type of procedure to anyone for security reasons. I recommend either reinstalling the version or upgrading.

  • 1

    Augusto, thanks for the answers, but I had to find another solution... I followed the contribution note in the PHP dbase manual, and it was much easier rs https://www.php.net/manual/en/book.dbase.php

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.