Hello guys, I have a school assignment and I need to develop a site with Microsoft Access database, but I have no clue how to set up and use that database, I searched eveywhere on the internet and I haven't found anything concludent, all explications are foggy and I can't understand them. Can you please explain what $db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbName; Uid=; Pwd=;"); means?.
Exactly what does "dbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbName; Uid=; Pwd=;" mean and how do I find it in my computer, or do I have to install a driver ? Please help me, I really need your help.

"Driver" points to the installed windows driver needed to access the MSAccess database. Most likely this is already installed if you are running on a Windows machine. $dbName is a variable that should contain the name of the database you are trying to open.

Sorry for asking but I am a bit newbie with Microsoft Acces, but where is this driver located ?

In the control panel, under ODBC data sources it should be visible.

Create your Access database and populate it.
You will need to install ODBC before you can access your database by downloading it from;
http://dev.mysql.com/downloads/connector/odbc/

Upon installing it, then follow the following instructions;
1. Go to your control panel and Open the Administrative Tools icon in your Control Panel.
2. Double-click on the Data Sources (ODBC) icon inside.
3. Choose the System DSN tab.
4. Click on Add in the System DSN tab.
5. Select the Microsoft Access Driver. Click Finish.
6. In the next screen, click Select to locate the database.
7. Give the database a Data Source Name (DSN).
8. Click OK.

Then you can connect to your database. Note that you only need to connect to the datasource and NOT the database itself like so;

$conn=odbc_connect('data_source','','');
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);

Hope that helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.