Connect to a remote MS SQL database

------=_Part_3214_9640935.1169675706563
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

------=_Part_3214_9640935.1169675706563--
jordanmueller [ Mi, 24 Januar 2007 22:55 ] [ ID #1606977 ]

Re: Connect to a remote MS SQL database

> 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);
eriam [ Do, 25 Januar 2007 09:09 ] [ ID #1608443 ]

RE: Connect to a remote MS SQL database

FYI, This works for me.

my $dbh =3D DBI->connect('DBI:ODBC:Driver=3D{SQL
Server};server=3D{SVR12};database=3D{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 [mailto:jordanmueller [at] gmail.com]
Sent: Wednesday, January 24, 2007 2:55 PM
To: dbi-users [at] 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 =3D 'driver=3D{SQL Server};Server=3D<server_name>;
database=3D<database_name>;uid=3D<username>;
pwd=3D<passwrd>;';

my $dbh =3D 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
campbelb [ Di, 30 Januar 2007 22:07 ] [ ID #1613461 ]
Perl » perl.dbi.users » Connect to a remote MS SQL database

Vorheriges Thema: issue in locating Dynaloader
Nächstes Thema: Clob insert problem on a Oracle db with DBI