I seem to have found my own answer… Thanks all the same…

For those of you who might be interested, the problem was the way I had
defined my ODBC connection in Windows. I had configured a User connection
which works just peachy for command line perl. This is because command line
perl is executed as the user that is logged in. When running in apache you
need to have a System connection set, because apache does not run as the
logged in user.

I found a great explanation of this problem at:
http://xmlproj.dyndns.org/faqomatic/cache/6.html

Thanks again!


Paul Russell
[EMAIL PROTECTED]

-----Original Message-----
From: Paul Russell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 28, 2002 4:29 PM
To: [EMAIL PROTECTED]
Subject: Error connecting to MS SQL when running in Apache

I am having a problem moving a perl script I am using on the command line
into apache due to an error connecting to MS SQL.

My Environment:
Windows 2K professional
SQL Server 2000
Apache 2
Perl 5.6.1
DBD::ODBC v 0.28

Here is the problem:

When run on the command line I am able to connect to the DB with no problem
using the following code:

my $db_handle = DBI->connect( 'DBI:ODBC:local_db', ‘username’, 'password',
{ RaiseError => 1 } );

All is well except that I’m running on windows and using MS SQL…. ;)


The problem arises when I use this same code in a CGI running in apache I
receive the following error.

            [Microsoft][ODBC Driver Manager] Data source name not found and
no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1)

I realize that apache probably needs more information in order to connect to
the DB, so I have tried several ways of defining the DSN. One of them
follows:

            my $db_handle = DBI->connect(
'DBI:ODBC:local_db@servername:1433', ‘username’, 'password', { RaiseError =>
1 } );


No matter how I attempt to define the connection, it always gives me the
same error:

[Microsoft][ODBC Driver Manager] Data source name not found and no default
driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1)


I know I’m missing something simple, but I’m at a loss. How do I get a CGI
that works on the command line to connect to a DB when running in apache?


Thanks in advance!

Paul


Paul Russell
[EMAIL PROTECTED]

Reply via email to