Opening more than one connection to Database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tembss
Forum Newbie
Posts: 2
Joined: Tue May 13, 2003 7:33 am
Location: RSA

Opening more than one connection to Database

Post 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! :?
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post 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'.
Post Reply