Perl Code Connects to Database Across IP and Not Host Header

R

rminnis82

I am not sure if this is a Perl or MS IIS 6.0 issue, but I have a
page.pl sitting on a webserver. The perl script connects to a MS SQL
Server 2005 database on teh same server. The ODBC is all setup and
working.

I have the perl script setup in IIS as a virtual directory in Default
Website AND under a new Website with host headers.


With the virtual directory, if I type http://[external
IP]/DOMAIN/page.pl, the page loads and shows all the data taken frm the
SQL database.

With the new website, if I type test.domain.com/page.pl, I get a
message saying:

Software error:
Cannot connect to db Domain

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


This is my code to connec to the DB:
my $dbh = DBI->connect("dbi:ODBC:Domain") ||
die "Cannot connect to db Domain\n";

$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
$dbh->{LongReadLen} = 1024;

I am running Perl using this installer:
ActivePerl-5.8.3.809-MSWin32-x86.msi


Can anyone see where I might be going wrong? Or is it just not feasible
to get access to page.pl using host headers.

Thanks in Advance.
 
M

Mark Clements

I am not sure if this is a Perl or MS IIS 6.0 issue, but I have a
page.pl sitting on a webserver. The perl script connects to a MS SQL
Server 2005 database on teh same server. The ODBC is all setup and
working.

I have the perl script setup in IIS as a virtual directory in Default
Website AND under a new Website with host headers.


With the virtual directory, if I type http://[external
IP]/DOMAIN/page.pl, the page loads and shows all the data taken frm the
SQL database.

With the new website, if I type test.domain.com/page.pl, I get a
message saying:

Software error:
Cannot connect to db Domain

I'm not particularly familiar with IIS, but I imagine you need to output
the http headers yourself.

use CGI;

my $cgi = CGI->new();

print $cgi->header();


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


This is my code to connec to the DB:
my $dbh = DBI->connect("dbi:ODBC:Domain") ||
die "Cannot connect to db Domain\n";

You're ignoring the error message from DBI;

my $dbh = DBI->connect("dbi:ODBC:Domain") ||
die $DBI::errstr;
 
D

DJ Stunks

I am not sure if this is a Perl or MS IIS 6.0 issue, but I have a
page.pl sitting on a webserver. The perl script connects to a MS SQL
Server 2005 database on teh same server. The ODBC is all setup and
working.

I have the perl script setup in IIS as a virtual directory in Default
Website AND under a new Website with host headers.


With the virtual directory, if I type http://[external
IP]/DOMAIN/page.pl, the page loads and shows all the data taken frm the
SQL database.

With the new website, if I type test.domain.com/page.pl, I get a
message saying:

Software error:
Cannot connect to db Domain

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


This is my code to connec to the DB:
my $dbh = DBI->connect("dbi:ODBC:Domain") ||
die "Cannot connect to db Domain\n";

$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
$dbh->{LongReadLen} = 1024;

I am running Perl using this installer:
ActivePerl-5.8.3.809-MSWin32-x86.msi


Can anyone see where I might be going wrong? Or is it just not feasible
to get access to page.pl using host headers.

Thanks in Advance.

my WAG: your test.domain.com/page.pl doesn't have the permissions to
access your ODBC DSN the way your http://[external IP]/DOMAIN/page.pl
does. If I'm right, you shoudl be able to fix it by configuring your
DSN as a System DSN (rather than User DSN).

-jp
 
R

rminnis82

The DSN is already set up as System DSN and not User.

The error occurs when trying to connect to the database when the page
is called from IIS...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top