ODBC text file connect problem
| From: | Ethan Nelson | Date: | Tue, 10 Sep 2002 18:38:19 +0000 |
| Subject: | ODBC text file connect problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-115874@lists.php.net to get a copy of this message | ||
Good morning...
I've got one for ya. I've been trying to conenct to a csv text file (comma delimited,
\r\n row separators, and " text qualifiers) using the odbc_connect command and then run simple
select statements through it. It doesn't work and I'm at a loss for why. Here's the
meat (I replace anything potentially sensitive with ***):
ODBC connection: Microsoft text driver version 4.00.6200.00 Win2K IIS 5.0.
ODBC schema: I have specified, for the particular file I am trying to connect to, column name
headers and ANSI format. That's it...
// ODBC PHP connect string:
$odbc = odbc_connect("***input","",""); // This appears to work as no
errors are reported
// ODBC commands to explore connection:
$result = odbc_tables($odbc);
odbc_fetch_into($result,$row);
print_r($row);
// I get the following output to the screen:
Array ( [0] => ***:\***\***\*** [1] => [2] => inputfile.txt [3] => TABLE [4] => )
// Further commands to select data from text file:
$result = odbc_exec($odbc,"SELECT * FROM inputfile.txt");
// ERROR to screen:
Warning: SQL error: [Microsoft][ODBC Text 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 SQLExecDirect in ***:\***\***\***\basecsv2.html on line 53
PHP Warning: SQL error: [Microsoft][ODBC Text 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 SQLExecDirect in ***:\***\***\***\basecsv2.html on
line 53
Any ideas?
-Ethan, Modulus, LLC