The Microsoft Open Database Connectivity (ODBC) is a C application programming language interface. So the applications can access data from different database management systems. Â The designers of ODBC aimed to make it independent of database systems and operating systems. In this article, we are using the Microsoft Access database to establish a connection.
Requirements: If ODBC Drivers are installed or the old version is installed, then update to the latest version or install the driver firstÂ
- Start XAMPP server by starting Apache
- Write PHP script for Access database connection.
- Run it in a local browser.
- The database is successfully connected.
Steps to follow for ODBC connection to an MS Access Database:
- Open the Administrative tools icon in your control panel

- Double-click on the Data Sources (ODBC) icon inside.

- Choose the System DSN tab.
               Â

- Click on Add in the System DSN tab.

- Select the Microsoft Access Driver, Click Finish

- In the next screen, click on select to locate the database

- Give the database a Data Source Name (DSN) as shown in the above image. Click ok.
Example: The following example demonstrates the simple connection script.
<!DOCTYPE html>
<html>
<body>
<?php
//Storing DSN(Data Source Name created)
$dsn="raj";
$user="root";
$password="";
//storing connection id in $conn
$conn=odbc_connect($dsn,$user, $password);
//Checking connection id or reference
if (!$conn)
{
echo (die(odbc_error()));
}
else
{
echo "Connection Successful !";
}
//Resource releasing
odbc_close($conn);
?>
</body>
</html>
 Below output will be shown on the browser
Output:Â
Connection Successful !
Â