Perl Code Connects to Database Across IP and Not Host Header

Discussion in 'Perl Misc' started by rminnis82@hotmail.com, Dec 19, 2006.

  1. Guest

    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.
    , Dec 19, 2006
    #1
    1. Advertising

  2. wrote:
    > 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;


    > $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.
    >
    Mark Clements, Dec 21, 2006
    #2
    1. Advertising

  3. DJ Stunks Guest

    wrote:
    > 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
    DJ Stunks, Dec 21, 2006
    #3
  4. Guest

    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...
    , Dec 27, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matrix
    Replies:
    0
    Views:
    875
    Matrix
    Jan 18, 2005
  2. LamSoft

    ASPX VB.NET Connects to WMI

    LamSoft, Jun 4, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    715
    Mark Rae
    Jun 4, 2007
  3. DevX
    Replies:
    7
    Views:
    400
  4. Ramon
    Replies:
    21
    Views:
    856
    Nigel Wade
    Feb 23, 2009
  5. Casey Hawthorne
    Replies:
    3
    Views:
    329
Loading...

Share This Page