perlac has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl script that runs fine from the command-line but errors when called from an html page.

The error is 911 Microsoft ODBC Driver Manager Data source name not found and no default driver specified.

I'm using activestate perl version 5.6.1 with ODBC32 version 3.520 on a windows 2k box.

I compared environment settings and all seems to be ok...but, I'm a rookie at this. Can someone help?

Script and HTML Code included.

#!/ap5/bin/perl use Win32::ODBC; $dsn = "ProductionConnect"; if ($db = new Win32::ODBC($dsn)) { $sql = "select campcd, campdesc from crcampcd where campcd = 'AC'"; $db->Sql($sql); print "Content-type: text/html\n\n"; print "<HTML>\n"; print "<HEAD><TITLE>DB Test</TITLE></HEAD>\n"; print "<BODY>\n"; print "Connection Successful...\n\n"; while ($db->FetchRow()) { ($code, $descr) = $db->Data("campcd", "campdesc"); print "$code\n"; print "$descr\n"; print "</BODY>\n"; print "</HTML>\n"; }} else { #($ErrNum, $ErrText, $ErrConn) = $db->Error(); print "Content-type: text/html\n\n"; print "<HTML>\n"; print "<HEAD><TITLE>DB Test</TITLE></HEAD>\n"; print "<BODY>\n"; print Win32::ODBC::Error(); #print "Connection Failed...\n\n"; #print "$ErrNum\n"; #print "$ErrText\n"; #print "$ErrConn\n"; print "</BODY>\n"; print "</HTML>\n"; } $db->Close(); exit(0);
<html><head><title>DB Test</title> <basefont size=5></head> <body> <a href="http://localhost/cgi-bin/dbtest.cgi">Run Test</a> </body> </html>

Best Regards,

R Crawford

Replies are listed 'Best First'.
Re: Win32 ODBC Problem
by strat (Canon) on Jun 26, 2003 at 16:22 UTC
    Do you want to access a user- oder system-DSN? If it is a user DSN, beware that under NT, the webserver scripts may run under a useraccount like IUSR_servername.

    Maybe Re: DSN's might also be interesting for you

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

Re: Win32 ODBC Problem
by Grygonos (Chaplain) on Jun 26, 2003 at 16:13 UTC
    Assuming the database you want is on your local machine... Try setting the data source is setup under the System DSN tab on the ODBC admin tool. This makes it visible to all users on the system.. Setting it up under the User DSN makes it visible only to the user who set it up. also check that the driver for your database type is installed under the drivers tab. Hope this helps..

      All who responded

      I should have included this info in my first message...

      The DSN is defined as a system DSN. The user as per my browser env settings gathered using a perl script, is a member of the group administrator and the web server is IIS 5. As well, I am connecting to an informix 7.3 database.

      Best regards,

      R Crawford

Re: Win32 ODBC Problem
by perlac (Initiate) on Jun 27, 2003 at 19:00 UTC

    Many Thanks...

    The problem has been resolved--the IUSER did not have needed permissions.

    R Crawford