Page 1 of 1

Opening more than one connection to Database

Posted: Tue May 13, 2003 7:33 am
by tembss
I am opening more than one connection to an access database using and I get an error. At first I used the same connection handler, then I changed the name for the connection handler, but still got an error. An example of the code is:
$db = 'php/db/SPDB.mdb'; // path to the database
$_SESSION['dbConn'] = new COM("ADODB.connection"); // connection handler
$_SESSION['dbConn']->open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=$db"); // open the connection
$strSQL = "Select * from USERS";
$rsData = $_SESSION['dbConn']->execute($strSQL); // execute sql
.....
// second connection handler
$_SESSION['conn'] = new COM("ADODB.connection"); // connection handler
$_SESSION['conn']->open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=$db"); // open the connection

while (!$rsData->eof) {
...
$sumSQL="SELECT sum(feepaid) as Payment FROM FEETABLE WHERE idnumber=".$rsData->Fields['idnumber']->value;
$rsSum = $_SESSION['conn']->execute($sumSQL);
...
$rsData->MoveNext;
}
Has someone found an easier way of going about this, as I do not want to close/lose the first connection. Help! :?

Posted: Tue May 13, 2003 7:36 am
by []InTeR[]
What i know of Resource Types, is that they cannot be stored in a session.

The connection must be made each time that the page is 'runned'.