Jump to content

Archived

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

s3rvant

Can't connect to network Access database

Recommended Posts

I've been searching Google and trying various methods to connect to a networked Access database all day... no luck.

 

I'm running Xampp Lite v.1.7.2 which runs Apache v.2.2.12 and PHP v.5.3.0 on Win XP.

 

I'm trying to use odbc_connect to connect to a access database I have on the network, but I keep getting the error: [Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data., SQL state S1000 in SQLConnect in C:\xampplite-1.7.2\htdocs\colormeter.php on line 4

 

The code I'm currently using is:

$db = '\\\\Servername\\Path\\Database.mdb';
$odbc_driver = 'driver={microsoft access driver (*.mdb)};dbq='.$db;
$conn = odbc_connect($odbc_driver,'','');

 

The network path has full permissions to everyone, but I've still tried to use both my local machine's username as well as my domain username, both with same error. I've tried using a COM connection with ADO, but it also fails. I've tried adding the database as a system DSN to no avail. With the DSN I had read that while Windows forces you to map the drive, you cannot use drive letters that way, so I went into the registery and changed to the path to the appropriate \\Server\file type path. Still no luck. I've also tried making connections to databases in other network shares, same error.

 

This code works great with a local database. I can connect and query local databases just fine. I only have trouble when it's on the network.

Share this post


Link to post
Share on other sites

On another note, when I set the database as a DSN and alter the registry to use the \\Server\\file path type, I also tried to make the Apache service use a domain user account, but the service wouldn't start that way. Not sure why I couldn't get the service to start, but I've seen more then one user say that they were able to use a domain account with the service and that it enabled the code I gave above to work.

Share this post


Link to post
Share on other sites

  having the same problem, have you found a solution as of yet?

Share this post


Link to post
Share on other sites

Had this issue as well. I only managed to connect to local database unfortunately.

Share this post


Link to post
Share on other sites

  The answers I've run across vary, I am confused about this:

  Sample Code:

 

$db = '\\\\Servername\\Path\\Database.mdb';

 

  Is it really 4 'back-slashes' before 'server name', then 2 in-between , as shown?  I did revised the 'odbc dsn' setup in the registry as a few tips had suggested, been a while since I dealt with 'UNC paths, etc.' so I'm trying to recall the proper syntax.

Share this post


Link to post
Share on other sites

Because \ is an escape character, as well as path separator in Windows, you  need to use it twice for each time you want to use it as path separator.

Share this post


Link to post
Share on other sites

Thanks Michl.

 

So should:  '\\\\Servername\\Path\\Database.mdb';

 

Actually be: '\\Servername\\Path\\Database.mdb';

 

?

 

 

Share this post


Link to post
Share on other sites

As I said, I never got it working to remote server, so I have no real idea how this string should look like.

Share this post


Link to post
Share on other sites

×
×
  • 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.