Microsoft access with PHP and PDO
10,954
Write the connection object like the following and save characters case.
$dbName = "E:\\path\\to\\db.mdb";
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)};charset=UTF-8; DBQ=$dbName; Uid=; Pwd=;");
Author by
Veronica
Updated on August 23, 2022Comments
-
Veronica over 1 year
I am trying to connect to my access database but cannot. I have on my Microsoft server 2008 with IIS 7. I keep getting this error message. SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. Not Sure what I am doing wrong. Any ideas would help.
<?php try { $conn = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\\staffing.mdb;Uid=Admin"); } catch (PDOException $e) { echo $e->getMessage(); } ?>
-
Veronica over 9 yearsThank you that worked Now I just have to figure how to query the access DB with PHP and PDO
-
Veronica over 9 yearsI was able to query the db just can't get my javascript code to work stackoverflow.com/questions/27068866/…
-
JustCarty over 5 yearsFWIW I had this problem and was tearing my hair out for ages. I was using the driver
Microsoft Access Driver (*.mdb, *.accdb)
instead of the one used in the answer. Thank you so much! -
JustCarty over 4 yearsA year later, and I can say that the real reason I couldn't get this to work is that I hadn't got the 64-bit version of the Access driver on my server.