PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1848
Number of posts: 5016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
When MS Acces db is opened, trying to connect to odbc fails Posted by GoodGrendel on 10 Mar 2004 at 12:01 PM
Hi all, when i have my Microsoft Acces database opened, and viewing some tables, and then i'm going to try to visit a php page i made viewing information from the database it gives this error:

Warning: odbc_connect(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Could not use '(unknown)'; file already in use., SQL state S1000 in SQLConnect in D:\inet-srv\web-root\test\FA.php on line 3

Now, what i'd like to have is where the php can always read and modify whats in the database, even when the database is opened in ms access.

Anyway, any clue on how to get rid of this error, and being able to work with both the php-odbc and the ms access at the same time?

kind regards,
Ivo Jonker
Report
Re: When MS Acces db is opened, trying to connect to odbc fails Posted by skylar on 10 Mar 2004 at 6:56 PM
I have no idea =P

Perhaps you could read the data, store it in local variables and close the connection each time you need to do something..

I dunno, and i kind of doubt anyone else here will =\
Snoochie Boochies

Report
Re: When MS Acces db is opened, trying to connect to odbc fails Posted by WitchHunter on 25 Jun 2004 at 12:25 PM
This message was edited by WitchHunter at 2004-6-26 9:6:2

This message was edited by WitchHunter at 2004-6-26 9:4:54

: I have no idea =P
:
: Perhaps you could read the data, store it in local variables and close the connection each time you need to do something..
:
: I dunno, and i kind of doubt anyone else here will =\
: Snoochie Boochies
:
:

How to connect and get data from an Access-Database:

... and put 'em into an Array using keys and values
use cut & paste, should work

<?PHP

$db = "db1.mdb";

$db_connection = new COM("ADODB.Connection");
$db_file = realpath($db);
$db_path = substr($db_file, 0, strrpos($db_file,'\\'));

/*
Be careful with this ... your Drivername might differ from
this one ... depends on Windows/Office-Language, etc.
Just open your ODBC to see what the right name is
*/

$db_connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".$db_file."; DefaultDir=".$db_path;

$db_connection->open($db_connstr);
$rs = $db_connection->execute($sql);

$fld = $rs->Fields;
$field_count = $fld->Count;

$cnt = 0;
while (!$rs->EOF)
{
for ($i=0; $i < $field_count; $i++)
{
$tmp = $rs->Fields($i);
$valueArr[$cnt][$tmp->name] = $tmp->value;
}
$cnt++;
$rs->MoveNext(); // updates fields!
}

// cleaning up
$rs->Close();
$db_connection->Close();
$rs=null;
$db_connection=null;
?>

Hope that helps,

greet$
WitchHunter







 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.