FAQ
Hello,

** First time posting, please excuse possible novice mistakes **

SETUP:
web server: win 32 Apache running on a windows 2003 server machine,
activePerl
database: MS SQL hosted on a separate windows server at my organization.

PROBLEM:
I cannot get my $dbh -> connect() line to work.

I have spent all day reading different documentation for DBI and DBD::ODBC,
as well as
different websites, and I can't make a connection.

Does anyone have experience with these Microsoft beasts?

Here is the sample code that I have hobbled together from different docs:

++++++++++++++++++++++++++++++++++++++++++++++++++++
use DBI;
use strict;
use diagnostics;

my $data_source = 'driver={SQL Server};Server=<server_name>;
database=<database_name>;uid=<username>;
pwd=<passwrd>;';

my $dbh = DBI->connect("dbi:ODBC:$data_source") or die "$DBI::errstr";
++++++++++++++++++++++++++++++++++++++++++++++++++++

I do not have the errors, because I do not have read access to the error
logs right now, and
CGI::carp is not working correctly.

Also, I checked and ODBC is listed as an available driver for DBI.


I would appreciate if anyone has some light to shed on the problem.


Thank you,

Jordan Mueller
Data Manager
Brigham and Women's Hospital

Search Discussions

  • Eriam Schaffter at Jan 25, 2007 at 8:02 am

    I do not have the errors, because I do not have read access to the error
    logs right now, and
    CGI::carp is not working correctly.
    I suggest that you try to get the errors, it will be much easier to debug.

    You can still redirect STDERR to a file and then read that file (if you
    can create and read files on the server).

    open(STDERR, '> local_error_log');

    (...)

    close(STDERR);
  • CAMPBELL, BRIAN D \(BRIAN\) at Jan 30, 2007 at 9:07 pm
    FYI, This works for me.

    my $dbh = DBI->connect('DBI:ODBC:Driver={SQL
    Server};server={SVR12};database={Review};');

    Perl 5.8.7
    DBI 1.53
    DBD-ODBC 1.13
    Perl is running on Windows XP, and connecting to a SQL server.

    Our captilizations differ, but that's not an issue. I tried your
    capitalizations and they worked too. I tried your embedded newlines and
    that worked too.

    I'm not sure if this is the right terminology: the server recognizes the
    login domain, and so I'm automatically authenticated. I don't need a
    userid and password. Indeed I need to leave them off. If I add a
    userid and password the server returns a login failure. I don't know if
    this would apply in your environment.

    -----Original Message-----
    From: Jordan Mueller
    Sent: Wednesday, January 24, 2007 2:55 PM
    To: dbi-users@perl.org
    Subject: Connect to a remote MS SQL database

    Hello,

    ** First time posting, please excuse possible novice mistakes **

    SETUP:
    web server: win 32 Apache running on a windows 2003 server machine,
    activePerl
    database: MS SQL hosted on a separate windows server at my organization.

    PROBLEM:
    I cannot get my $dbh -> connect() line to work.

    I have spent all day reading different documentation for DBI and
    DBD::ODBC, as well as different websites, and I can't make a connection.

    Does anyone have experience with these Microsoft beasts?

    Here is the sample code that I have hobbled together from different
    docs:

    ++++++++++++++++++++++++++++++++++++++++++++++++++++
    use DBI;
    use strict;
    use diagnostics;

    my $data_source = 'driver={SQL Server};Server=<server_name>;
    database=<database_name>;uid=<username>;
    pwd=<passwrd>;';

    my $dbh = DBI->connect("dbi:ODBC:$data_source") or die "$DBI::errstr";
    ++++++++++++++++++++++++++++++++++++++++++++++++++++

    I do not have the errors, because I do not have read access to the error
    logs right now, and CGI::carp is not working correctly.

    Also, I checked and ODBC is listed as an available driver for DBI.


    I would appreciate if anyone has some light to shed on the problem.


    Thank you,

    Jordan Mueller
    Data Manager
    Brigham and Women's Hospital

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbi-users @
categoriesperl
postedJan 24, '07 at 9:55p
activeJan 30, '07 at 9:07p
posts3
users3
websitedbi.perl.org

People

Translate

site design / logo © 2022 Grokbase