Hello All,
I am using PHP5. I am trying to connect PHP5 with Access 2007 using DSN less connection. I am using the following code to connect the database.
$conn = new COM(“ADODB.Connection”) or die(“Cannot start ADO”);
// Microsoft Access connection string.
$conn->Open(“DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=E:\\xampp\\htdocs\\ams\\MyPayroll1.mdb”);
// SQL statement to build recordset.
$rs = $conn->Execute(“SELECT EmpCode FROM Emp_Mast”);
echo “<p>Below is a list of values in the MYDB.MDB database, MYABLE table, MYFIELD field.</p>”;
// Display all the values in the records set
while (!$rs->EOF) {
$fv = $rs->Fields(“empcode”);
echo "Code: “.$fv->value.”<br>
";
$rs->MoveNext();
}
$rs->Close();
When i am connecting the DB with the above code it’s connecting correctly and gives me the result. The DB is in my local system.
But when i used the same code to connect the Access DB which is another system it gives me the following error.
Fatal error: Uncaught exception ‘com_exception’ with message ‘<b>Source:</b> Microsoft OLE DB Provider for ODBC Drivers<br/><b>Description:</b> [Microsoft][ODBC Microsoft Access Driver] ‘(unknown)’ is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.’ in E:\xampp\htdocs\ams\ est_dsnless.php:7 Stack trace: #0 E:\xampp\htdocs\ams\ est_dsnless.php(7): com->Open(‘DRIVER={Microso…’) #1 {main} thrown in E:\xampp\htdocs\ams\ est_dsnless.php on line 7
$conn->Open(“DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=E:\\xampp\\htdocs\\ams\\MyPayroll1.mdb”);
for this code i have replaced with
$conn->Open(“DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\\192.168.1.101\\d$\\xampp\\htdocs\\ams\\ estemp.mdb”);
Please anyone help me to get out of this error.
Thanks in Advance