Avatar of DrDamnit
DrDamnitFlag for United States of America

asked on 

ODBC Connection to Access database with PHP

I followed the steps here:
http://www.devasp.com/samples/dsn_access.asp

and created a DSN, which went OK.

Then I tried to use this code to access it, but it keeps failing. $conn is empty.
 
<?php
	$conn=odbc_connect('MCDB','phpadmin','********!');
	if (!$conn)
	{
		exit("Connection Failed: " . $conn);
	}
	else
	{
		echo "Connection Established";
	}
	odbc_close($conn);
?>

Open in new window


What am I doing wrong?
PHPMicrosoft Access

Avatar of undefined
Last Comment
Lukasz Chmielewski
Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

If so... Seems ok but double check:
DSN name ? Is it the same ?
Are you providing good password ?
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

ASKER

Since this is a Windows 2k8 box, there is no user and password because I have used a system DSN.

In that same vein, I have manually added some user / passwords to the DSN, and I have also tried authenticating with the system administrator credentials (with and without the DOMAIN\User format). All to no avail.

ODBC is already installed on a Windows SBS 2008 box, so I don't think I need to install anything else. I did, however have to install the access drives, but that went ok.
Does this work without providing ANYTHING ?
$conn=odbc_connect('MCDB','','');
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

ASKER

No joy.

I have set the file permissions to this as Everyone = Full Access (for the folder that contains this file). Still didn't work.

Thoughts?
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

ASKER

This is how I set it up... User generated image User generated image User generated image
ASKER CERTIFIED SOLUTION
Avatar of Shinesh Premrajan
Shinesh Premrajan
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

ASKER

Still fails. Just to beclear, dbq should be the DSN or the path to the file?
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

ASKER

The key was to do a DSN-less connection using the full path. Thanks!
Isn't that the thing suggested by the first post ?
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo