0

A client has an Microsoft Access database where they save their products. To access the database now you have to login via VPN and open Microsoft Office Access.
I need to access this database from a PHP script running on another server.

I've done some research and found that it's not possible to connect to an Access database like a MySQL database.
So what I wonder is if it may be possible to set up an Microsoft SQL Server on the same server that uses the Microsoft Access database. So I can connect to the Microsoft SQL Server with the PHP script. Or if it's possible MySQL.

They are running Microsoft Windows Server 2008 and Microsoft Office Access 2003.

1

An access database is not a server, it's just a file. To access it, your server will need access to the filesystem on which it resides. Or, if you want to set up an SQL server on the same machine as the access database, it will still need access to the folder in which the file is stored.

A user logged into a VPN may not have the same drive mappings or file system permissions as a server process running on the same machine, so you will need to reflect this in the path to the file you use in the code.

0

I thought you could use php to connect to an Access database.

Here's the php manual on this topic: http://php.net/manual/en/function.odbc-connect.php

And a code sample from that page connecting to Access database.

<?php
// Microsoft SQL Server using the SQL Native Client 10.0 ODBC Driver - allows connection to SQL 7, 2000, 2005 and 2008
$connection = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $password);

// Microsoft Access
$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", $user, $password);

// Microsoft Excel
$excelFile = realpath('C:/ExcelData.xls');
$excelDir = dirname($excelFile);
$connection = odbc_connect("Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=$excelFile;DefaultDir=$excelDir" , '', '');
?>
  • Looks good. But I guess this code has to run on the same server as the Access database? – Patrik Sep 9 '13 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.