insert to .mdb without DSN / with ADODB

admin

Administrator
Staff member
Hello,
I got the problem, having to connect via PHP to several .mdb Access Databases located on an ISPs NT-Server,
Unfortunately there are no more DSN-Entries available (the Maximum is 3) and changing the whole existing site / database strucutre would be terrible due to the complexity of the site.
So i guess there's no possibility to use odbc_connect, true ?

Assuming this i gave ADODB a try.
Reading and printing the records works fine.
Below is the script.
(taken mostly from <!-- m --><a class="postlink" href="http://php.weblogs.com/adodb">http://php.weblogs.com/adodb</a><!-- m --> , thanks )


<?
$A = $PATH_TRANSLATED;
$B = strrev ($A);
$C = strstr ($B ,'\\');
$D = strrev ($C);


$dbc = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)};";
$connstr .= "DBQ=".$D."testdb.mdb;uid=;pwd=;";
$dbc->open($connstr);
$rs = $dbc->execute("SELECT * FROM Element");
while(!$rs->eof()) {
print $rs->fields['Gruppe']->value();
print " | ".$rs->fields['Element']->value()."";
print " | ".$rs->fields['Key']->value()."";
print "\n<BR>\n";
$rs->movenext();
}

$dbc->close();
?>

But as soon as i put this statment into the skript

$a = 1;
$b= 2;
$c= 3;
$sql = "INSERT INTO Element (Gruppe,Element,Key) values('$a','$b','$c')";
$dbc->execute($sql);

it obviously isn't executed completely,simply ends with an "CGI-Execution Timeout" error and the .mdb database remains unchanged.

I'd appreciate any help on what i might be doing wrong here very much.

Sincerely

Oliver
 
Back
Top