Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database handle destroyed without explicit disconnect 1

Status
Not open for further replies.

sophiatan

Programmer
Apr 10, 2001
8
SG
I keep getting the error, even though I'm very sure I disconnect properly. I have a function that connects, querys then disconnect and I always access the DB using that function.

I'm running ActivePerl (build 522) on Win2k with MS SQL 7, and velocigen. I'm not sure if it's a velocigen error, as the problem seemed to be at D:\VelociGen\site\lib\Apache\DBI.pm, I don't understand why it's using the DBI.pm under the Apache dir instead of the D:\VelociGen\site\lib\DBI.pm since I'm running IIS.

Can anyone help me or does someone have this same problem?

 
You need to let the database know this the last query that that used the connection to the database is finished. Try using this $sth->finish; before u disconnect. I am making the assumption that you are using the DBI module to connect to the data base.
&con;<--subrouting to connect
$sth=$dbh->prepare (qq{
SELECT pass FROM playerdata WHERE handle=?
} );
$sth->execute ($user);
$sth->bind_columns (\$pass);
$sth->fetch;
$sth->finish;

&dis;<subrouting to disconnect
 
Yes, I'm using DBI module, I've attached my function below.

sub queryDb {
my ($DSN,$DSNuser,$DSNpassword,$sql,@params) = @_;

my $dbh = DBI->connect($DSN,$DSNuser,$DSNpassword);
my $stmt=$dbh->prepare ($sql);
$stmt->execute(@params);
my @ans = $stmt->fetchrow_array;
$stmt->finish;
$dbh->disconnect;

return @ans;
}

By the way, the problem seemed sporadic, of course I can just turn off the warning with $dbh->{Warn} = 0, but I would like to know what cause the error in the first place.
 
A note to add on the 'sporadic' behaviour. Apparently, the first time I run the script (any script), the error doesn't come out. But there after, it keeps coming out.
 
Could you try testing the return code of disconnect() and the looking at the value in $DBH::errstr ? Mike
________________________________________________________________________________

&quot;Experience is the comb that Nature gives us, after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top