php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77252 PDO ODBC.accdb cannot connect
Submitted: 2018-12-06 16:48 UTC Modified: 2020-10-18 04:22 UTC
Votes:8
Avg. Score:4.8 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:7 (87.5%)
Same OS:6 (75.0%)
From: xxalfa at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: PDO ODBC
PHP Version: 7.3.0 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
7 + 30 = ?
Subscribe to this entry?

 
 [2018-12-06 16:48 UTC] xxalfa at gmail dot com
Description:
------------
Fatal error: Uncaught PDOException: SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager]
The data source name was not found, and no default driver was specified in C:\test.php:29
C:\test.php(29): PDO->__construct('odbc:Driver={Mi...')
With an older PHP version it worked.

Test script:
---------------
<?php

    //-------------------------------------------------
    // HEAD
    //-------------------------------------------------

    declare( strict_types = 1 );

    error_reporting( -1 );

    ini_set( 'html_errors', '0' );

    ini_set( 'display_errors', '1' );

    define( 'CORE_DIR', dirname( __FILE__ ) . DIRECTORY_SEPARATOR );

    header( 'Content-Type:text/plain' );

    //-------------------------------------------------
    // CODE
    //-------------------------------------------------

    echo PHP_VERSION . PHP_EOL;

    extension_loaded( 'pdo_odbc' ) or trigger_error( 'The pdo odbc extension is required.', E_USER_ERROR );

    $database_path = CORE_DIR . 'test.accdb';

    file_exists( $database_path ) or trigger_error( 'Could not find database file.', E_USER_ERROR );

    $database = new PDO( 'odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=' . $database_path );

    // $database = new PDO( 'odbc:Driver={Microsoft Access Driver (*.accdb)}; Dbq=' . $database_path . '; Uid=; Pwd=;' );

    // $database = odbc_connect( 'Driver={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=' . $database_path, '', '');

?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-06 23:16 UTC] cmb@php.net
-Package: ODBC related +Package: PDO ODBC
 [2020-09-29 11:59 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-09-29 11:59 UTC] cmb@php.net
That works fine for me with current PHP 7.3.

Maybe there is a permission issue in your setup?
 [2020-10-05 15:01 UTC] xxalfa at gmail dot com
I tested it again, it works with PHP 7.3.23 x86. But I would like to use x64. When I try to use the current PHP version 7.4.11 x86 / x64, I get the following error: PHP Warning: 'vcruntime140.dll' 14.0 is not compatible with this PHP build linked with 14.16 in Unknown on line 0
 [2020-10-05 15:05 UTC] cmb@php.net
Thanks for the swift feedback!

Apparently, you have a pretty old vcruntime140.dll; just download
the latest VC redistributable[1] and install it.

[1] <https://aka.ms/vs/16/release/VC_redist.x64.exe> (direct download link).
 [2020-10-18 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 23 22:01:26 2020 UTC