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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl DBI

Status
Not open for further replies.

bknox

Technical User
Apr 13, 2004
30
US
I am writing perl scripts that interface to a Access DB through the Win32:ODBC DBD module. I am using the same connection parameters across all my scripts. They look like the following:

###########################################################
#!c:\Perl\bin\perl.exe -w
use dbi;
use Win32::ODBC;
use CGI ':standard';

print "content-type: text/html \n\n";

#Set up DSN connection settings
$DriverType = "Microsoft Access Driver (*.mdb)";
$DSN = "Win32 ODBC";
$Dir = "c:\\";
$DBase = "po.mdb";


#Intialize PO database temporary DSN
Win32::ODBC::ConfigDSN(ODBC_ADD_DSN, $DriverType,
("DSN=$DSN", "Description=Database Connection", "DBQ=$Dir\\$DBase", "DEFAULTDIR=$Dir", "UID=", "PWD="))
or die "ConfigDSN(): Could not add temporary DSN" . Win32::ODBC::Error();

#Connect to PO DB
$db=new Win32::ODBC($DSN) or die "couldn't open DB: $DSN because ", Win32::ODBC::Error(), "</br>";

$db->Close();
###########################################################

My problem is this: If I call one script from another...I.E if an event occurs I go to another script. The problem is that in the called script Anything passed the ConfigDSN() method doesn't get executed.

Any help is appreciated
 
The DIE command does not run.
 
bknox,

You are looking at your error logs for evidence of the die statement?
--Paul
 
Correction the DIE command is executing. Here is the message:

Software Error

ConfigDSN(): Could not add temporary DSN at C:\Inetpub\Scripts\searchemp.pl line 26

For help, please send mail to this site's webmaster, giving this error message and the time and date of the error

Ben
 
bknow,

This looks like your Access Database won't permit more than one connection at a time, and because you're calling your script from a script which has already a connection on the database.

I'm not sure, but it looks like that.

Can you leave all your database handling to subjugate scripts?

--Paul
 
That is what I thought to, but I declared 2 db handles in a separate script and it worked fine. I even executed multiple sql statments to test it, and it worked fine.

Ben
 
How did you create the 2 handles?

Can you use the syntax for the second handle in your subjugate scripts?

--Paul
 
The syntax is the same except the $DSN variable changed to $DSNNUM and the db handle changed to $dbtwo. I am not exactly sure what you mean by subjugate scripts?

Ben
 
Scripts you're calling from the main script.

It could be that some of the info that's in the connect string is being stored in the database, and it's causing a clash because the two handles are effectively the same

Just a thought
--Paul

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top