Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Perl, DBI, IIS question

by zuma53 (Beadle)
on Feb 05, 2013 at 22:24 UTC ( #1017290=perlquestion: print w/ replies, xml ) Need Help??
zuma53 has asked for the wisdom of the Perl Monks concerning the following question:

Hi--

I have a simple Perl script that logs in to a MSSQL database and creates an HTML page from a simple query.

When I run the script from the command line, the resulting output is OK. I am able to have the webserver open a static file with the results.

However, when I have the webserver run the script, I get the following error:

[Microsoft][ODBC Driver Manager] Data source name not found and no def +ault driver specified (SQL-IM002)
The DSN is set up as a System DSN and it is able to connect (otherwise the commnad-line would have failed).
my $dbh = DBI->connect("dbi:ODBC:DSN=XXX-ZZZZREP02")

Might this be a permissions issue? IIS is running under the local system acount and I am connecting to the DB via WinAuth.

Thanks in advance.

Comment on Perl, DBI, IIS question
Select or Download Code
Re: Perl, DBI, IIS question
by roboticus (Canon) on Feb 05, 2013 at 22:41 UTC

    zuma53:

    It might be permissions, but I think I'd suspect your ODBC data source definitions first. Are they system-level or user level?

    I get around that problem by explicitly giving DBD::ODBC the parameters for the database, rather than relying on a DSN definition. I don't recall the particulars, but thanks to [www://connectionstrings.com] they're pretty easy to find. Your connect string could boil down to something like this:

    my $DB = DBI::connect("DBD:ODBC:driver={ABCD};Server=ServerIPAddress;" ."User ID=yourUserName;Password=Password");

    To get the text for the ABCD slot, go into the ODBC definition thingie, and look at the list of drivers. DBI and/or DBD::ODBC may also have some methods for digging up the ODBC drivers.

    When your only tool is a hammer, all problems look like your thumb.

      That worked!



      Thanks

        What worked? A system-level DSN, or bypassing DSNs entirely? Did you try both?

      I'm sure roboticus knows this but it might also be useful to others like zuma53. If you create a DSN and successfully connect to it you can use DBD::ODBC's odbc_out_connect_string to get a connection string you can use later without the DSN.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1017290]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-09-20 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (159 votes), past polls