note 35331 added to function.odbc-connect

From: Date: Wed, 27 Aug 2003 23:08:47 +0000
Subject: note 35331 added to function.odbc-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-55192@lists.php.net to get a copy of this message
As always Microsoft is clueless... I've been trying to connect to an Access database on a W2K on the network (not a local file, but mapped on the V: drive), via ODBC. All I got is this message: Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides., SQL state S1009 in SQLConnect in d:\apache\cm\creaart.php on line 13 So... I started looking al around and looks like the ODBC driver has some severe problems: 1. It cannot access a Access database via a mapped drive. And this is for ANY application, name it PHP, Coldfusion, whatever 2. You cannot make a system DSN with a UNC (\\Server\resource), so you must map the drive Cute isn't it? So... I quit on ODBC and went via ADO, this is the code that works: === CODE === $db = '\\\\server\\resource\\db.mdb'; $conn = new COM('ADODB.Connection'); $conn->Open("DRIVER={Driver do Microsoft Access (*.mdb)}; DBQ=$db"); // Driver do Microsoft Access (*.mdb) // must be the name in your odbc drivers, the one you get // from the Data Sources (ODBC). // In this case, I'm in Mexico but the driver name is in portuguese, thanks Microsoft. $sql = 'SELECT username FROM tblUsuarios'; $res = $conn->Execute($sql); while (!$res->EOF) { print $res->Fields['username']->Value . "<br>"; $res->MoveNext(); } $res->Close(); $conn->Close(); $res = null; $conn = null; === /CODE === ---- Manual Page -- http://www.php.net/manual/en/function.odbc-connect.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35331 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35331&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35331&report=yes

« previous php.notes (#55192) next »