s3rvant Posted February 8, 2010 Share Posted February 8, 2010 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. Quote Link to comment Share on other sites More sharing options...
s3rvant Posted February 8, 2010 Author Share Posted February 8, 2010 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. Quote Link to comment Share on other sites More sharing options...
fuji36 Posted April 23, 2010 Share Posted April 23, 2010 having the same problem, have you found a solution as of yet? Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 23, 2010 Share Posted April 23, 2010 Had this issue as well. I only managed to connect to local database unfortunately. Quote Link to comment Share on other sites More sharing options...
fuji36 Posted April 23, 2010 Share Posted April 23, 2010 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. Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 24, 2010 Share Posted April 24, 2010 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. Quote Link to comment Share on other sites More sharing options...
fuji36 Posted April 24, 2010 Share Posted April 24, 2010 Thanks Michl. So should: '\\\\Servername\\Path\\Database.mdb'; Actually be: '\\Servername\\Path\\Database.mdb'; ? Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 24, 2010 Share Posted April 24, 2010 As I said, I never got it working to remote server, so I have no real idea how this string should look like. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.