Connect to a remote MS SQL database

Connect to a remote MS SQL database

am 24.01.2007 22:55:06 von jordanmueller

------=_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=;
database=;uid=;
pwd=;';

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--

Re: Connect to a remote MS SQL database

am 25.01.2007 09:09:35 von eriam

> 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);

RE: Connect to a remote MS SQL database

am 30.01.2007 22:07:16 von campbelb

FYI, This works for me. =20

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@gmail.com]=20
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 =3D 'driver=3D{SQL Server};Server=3D;
database=3D;uid=3D;
pwd=3D;';

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