I want to know how M/S ACCESS database can be connected to html page hosted on local host

Dani AI

Generated

On Windows localhost, the practical route is to run a web server (IIS, WAMP/XAMPP) and talk to your Access file via ODBC/OLE DB. For .accdb files, install the Microsoft Access Database Engine (ACE) runtime and match its bitness to your web stack (32-bit PHP/IIS with 32-bit ACE, or 64-bit with 64-bit ACE). You can get the ACE runtime from Microsoft at Microsoft Access Database Engine 2016 Redistributable. Place the .mdb/.accdb outside the web root and grant the web server account read/write NTFS permissions.

Example using PHP with PDO ODBC (Windows only):

<?php
$path = 'C:\\data\\db\\mydb.accdb'; // outside web root
$dsn  = 'odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=' . $path . ';Uid=;Pwd=;';
$db   = new PDO($dsn);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$stmt = $db->query('SELECT TOP 10 * FROM Customers');
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
header('Content-Type: application/json');
echo json_encode($rows);

Troubleshooting tips:

  • Bitness mismatch causes connection failures. On IIS, you can toggle Enable 32-Bit Applications on the app pool if you installed a 32-bit driver.
  • Access is file-based; concurrent writes are limited. Avoid long-running locks and ensure the .ldb/.laccdb lock file can be created.
  • If you prefer a DSN, create it with the correct 32/64-bit ODBC Administrator. PHP PDO ODBC docs are at PHP PDO_ODBC.

For anything beyond demos, consider a server engine (e.g., SQL Server Express or MySQL) for reliability and concurrency.

Recommended Answers

All 2 Replies

You will not be able to do this with HTML alone. You need to have server side scripting to be able to connect to a Database such as asp.net, php, asp, etc...

why not use mysql you can do it via wamp to run the php code.or use asp.net would be much easier to connect to a access db can runn it on IIS on you local machine.

with asp.net you could do something like that

`<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
data source=" & server.mappath("northwind.mdb"))
dbconn.Open()
sql="SELECT * FROM customers"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
customers.DataSource=dbread
customers.DataBind()
dbread.Close()
dbconn.Close()
end sub
</script>

<html>
<body>

<form runat="server">
<asp:Repeater id="customers" runat="server">

<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Companyname</th>
<th>Contactname</th>
<th>Address</th>
<th>City</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td><%#Container.DataItem("companyname")%></td>
<td><%#Container.DataItem("contactname")%></td>
<td><%#Container.DataItem("address")%></td>
<td><%#Container.DataItem("city")%></td>
</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>
</form>

</body>
</html>`

find out more on http://www.w3schools.com

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.