admanage - performance enhanced search technology

Connnecting to a MS ACCESS database

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

He has: 107 posts

Joined: Mar 2006

Hi,

I have tried lots of different ways but can't connect to a MS ACCESS database. All the example scripts assume the database has a password etc but what if it doesn't? I know how to connect to MySQL databases with PHP and it always connects, but don't know how to with ACCESS databases. Can someone provide some code to connect to an ACCESS database using ODBC?

Any help will be very much appresiated Wink

JeevesBond's picture
Moderator

He has: 3,465 posts

Joined: Jun 2002

Am assuming you're using PHP to connect? Think you can just use "" as the username/password are blank.

<?php
  $db_connection
= odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=/path/to/database\", \"\", \"\", \"SQL_CUR_USE_ODBC\");
?>

If that doesn't work, try:

<?php
  $db_connection
= odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=/path/to/database\", \"admin\", \"\", \"SQL_CUR_USE_ODBC\");
?>

'admin' is the default user (I believe). Hope this helps. Smiling

a Padded Cell our articles site!

He has: 107 posts

Joined: Mar 2006

Thanks, that worked!

carloncho's picture

They have: 18 posts

Joined: Jan 2008

What Access file version use?