Page 1 of 1

need help with connecting to Access database

Posted: Fri Jun 02, 2006 7:17 am
by gcapp
Hello,

I am new to php and I am having problems connecting to my Access database. The database is in the folder:
C:\inetpub\wwwroot folder.

I created a odbc connection. My database is called Accord and the connection is called Accord as well. I used it as a system database.

My php code looks like this:

Code: Select all

//$db = 'C:\\Inetpub\\wwwroot\\Accord.mdb';

//$conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');
//$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db") or exit('Cannot open with Jet.');
//$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db") or exit('Cannot open with driver.');

 $connect = odbc_connect("Accord", "", "");
At first I tried using the $db connection with Microsoft.Jet and I got the error "Cannot open with Jet".

Then I tried the $db with the .mdb driver and got the error "Cannot open with driver"

Then I tried using the obdc connection (that's why it is not commented out) and I am getting an error which states:

Warning: odbc_connect() [function.odbc-connect]: SQL error: , SQL state 00000 in SQLConnect in c:\Inetpub\wwwroot\accord\info.php on line 90. Line 90 being this line:

$connect = odbc_connect("Accord", "", "");


So can someone help me to connect to my Access database. I have been doing research on this, but can't seem to get it to work.

Any help would be appreciated.

Posted: Fri Jun 02, 2006 11:27 am
by RobertGonzalez
Some of this might be because of the connection string and some may be caused by the database itself. Have you looked into creating a DSN? Also, take a look at this website about connection strings. Hope it helps.

Posted: Fri Jun 02, 2006 11:31 am
by Burrito
can you connect to the datasource outside of php? IE, even from the datasource manager in windows?