For Programmers: Free Programming Magazines  


Home > Archive > PHP on Windows > November 2004 > Re: Re: [PHP-WIN] Permission deny on connecting MS Access database









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Re: [PHP-WIN] Permission deny on connecting MS Access database
Emperor Kang Xi

2004-11-30, 3:56 am






Hi,

Thanks michael, i have tired before, and wont run and produce the same error messages. But it can run with while the MDB file is at local drive (what i need is network drive).

but thanks alot anyway.. maybe i should try other way..





康熙





<michael@solanon.com>
Re: [PHP-WIN] Permission deny on connecting MS Access database










Hi,



 



Make sure the DB is not open by somebody else on the network (from the looks of things X is your network drive) or else add the Username and Password to the connection string.  If there are any other programs / websites accessing the database this could present a problem, in this case make sure that the apps / websites close their connections.  Try the below code and see if it works.  If that doesn't work then try to create a fresh database on your local drive and test that (It could be just that MS Access is crap ;)).



 



<?php



$conn = new COM("ADODB.Connection") or die("Cannot start ADO");




// Providing username and password exist (Make sure your OLEDB Driver version matches!)



$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=X:\mdb\mydata.mdb; UID=username; Password=yourpassword"); 
 



// Create and populate recordset             
$rs = $conn->Execute("SELECT * FROM sometable;");
 



// Loop through recordset and display 1 column from some table               
while (!$rs->EOF) {                
    $rs->Fields[somecolumnname]->Value;
    $rs->MoveNext(); 
 }     
 



// Close the recordset and destroy the object           
$rs->Close();
$rs->Release();
$rs = null;



 



// Close the connection and destroy object



$rs->Close();
$rs->Release();
$rs = null;



?>








----- Original Message -----



From: Emperor Kang Xi



To: php-windows@lists.php.net



Sent: Thursday, November 25, 2004 9:01 PM



Subject: [PHP-WIN] Permission deny on connecting MS Access database










Hi all,

I need help to solve my problem, I use ADO to connect MS Access database; the data is store in another server computer; I have try two different way to access the data, and below is the code:
-----------------------------------------
//$dbName = "\\SERVER\mdb\mydata.mdb";
$dbName = "X:/mdb/mydata.mdb";

$conn = new COM('ADODB.Connection');



$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=$dbName;Persist Security Info=False");

output:
------------------------------------------
Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft JET Database Engine Description: The Microsoft Jet database engine cannot open the file 'X:\mdb\mydata.mdb'. It is already opened exclusively by another user, or you need permission to view its data.


Thanks









康熙







Walla! Mail - get your free 1G mail today









--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





Walla! Mail - get your free 1G mail today

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com