Connnecting to a MS ACCESS database

They have: 105 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

He has: 3,956 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!

They have: 105 posts

Joined: Mar 2006

Thanks, that worked!

carloncho's picture

They have: 17 posts

Joined: Jan 2008

What Access file version use?

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.