Jump to content

connecting PHP with MS-Access


jawaidpk

Recommended Posts

hello members,

 

              I want to write a script that can connect to the MS-Access database & then fetch data from there

I got a code from a site which is as follows

 

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

 

<?php

 

// Two versions of Microsoft Office.  Choose one.

//$db = 'C:\\Program Files\\Microsoft Office\\Office\\Samples\\Northwind.mdb';

$db = 'C:\\Program Files\\Microsoft Office\\Office10\\Samples\\Northwind.mdb';

 

$conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');

 

// Two ways to connect. Choose one.

$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db") or exit('Cannot open with Jet.');

//$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db") or exit('Cannot open with driver.');

 

$sql = 'SELECT  ProductName, QuantityPerUnit, UnitPrice

FROM    Products

ORDER BY ProductName';

$rs = $conn->Execute($sql);

 

?>

 

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

 

but it generates an error like this "Cannot open with Jet.". Any one can help me regarding this error

Link to comment
https://forums.phpfreaks.com/topic/42312-connecting-php-with-ms-access/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.