SQLSTATE [IM002] SQLDriverConnect: Zero

Source: Internet
Author: User
Tags driver manager odbc connection
SQLSTATE [IM002] SQLDriverConnect: 0conn. php & lt ;? Phptry & nbsp; {& nbsp; $ conn & nbsp; new & nbsp; PDO (odbc: Driver {Microsoft & nbsp; access & nbsp; Driver & nbsp ;(*. mdb)}; SQLSTATE [IM002] SQLDriverConnect: 0
Conn. php
 try {
$conn = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=".realpath("../data/data.mdb"));
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
?>


Error prompt after running
Connection failed: SQLSTATE [IM002] SQLDriverConnect: 0 [Microsoft] [ODBC driver manager] no data source name found and default driver not specified

Baidu, Google, has been searching for a long time and does not know where the configuration is wrong. php_pdo_odbc.dll is enabled, phpinfo () also shows support for pdo/odbc, and the mdb file path is correct.

The system is win7sp1 x64.
PHP is 5.5.7 VC11 x64 Thread Safe
Apache is httpd-2.4.7-win64-VC11
Office is Office2010 x64

It is normal to use PDO to connect to the mysql database, but an error occurs when connecting to the mdb. Is it true that I have set an error or where to install or set a driver?

Share: More


------ Solution --------------------
It seems that the database does not support Access. in the new ACCDB format, you can use ACE to connect and try again.
Http://www.microsoft.com/en-us/download/details.aspx? Id = 13255
------ Solution --------------------
The code is correct. check whether the com extension is loaded.
Extension = php_com_dotnet.dll
Starting from php5.4, php for windows does not load the com extension by default. you need to configure it by yourself.

You are using an odbc Connection string instead of an odbc data source.
Therefore, PDO must use com to construct a data source.

------ Solution --------------------
Echo realpath ("../data. mdb ");
See what it is

Your connection string is certainly correct for Access2003
However, it is feasible for Access2010 because it cannot be tested.
Add Uid = Admin.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.