[TriLUG] Re: RHEL3 ->Perl ->MSSQL
Turnpike Man
turnpike420 at yahoo.com
Mon Dec 6 15:24:13 EST 2004
Thanks for posting your solution... I have wrestled with a similar issue
regarding LA(MSSQL)P solution here. I had hoped simply configuring unixODBC
and the ODBC for php would have been sufficient... but the process I had to go
through still required FreeTDS, ./configure with all kinds of options for PHP
and a small hack to the php.ini file to make it all work:
http://www.turnpike420.net/linux/Apache_PHP_FreeTDS_MSSQL2000.txt
That is one thing I cannot understand. What good are unixODBC and the PHP ODBC
modules if we can't use the packages as they are?? I'd really like to not have
to ./configure PHP and FreeTDS, but use the RPM package of PHP as is (and no
FreeTDS) in combination with the ODBC packages now being offered. This
solution seems to elude me. Google is hardly help here either. I've looked
for a long time and feel fortunate I found a solution that is at least working
for me at this time.
Anything enlightening anyone can offer, I'm all ears. (No, I can't switch
databases either.) :)
thanks,
David McD.
--- Steve Hoffman <srhoffman at gmail.com> wrote:
> Just wanted to post the solution because after all the googling I was
> only able to find one post that actually had the solution...naturally
> the last page I looked at so there could be more...on result pages
> 55-100
>
> Anyway...I didn't have enough information in the DSN...so even though
> I was passing a username/password in the perl script...because it
> wasn't in the ~/.odbc.ini file it wasn't working...the new ~/.odbc.ini
> file looks like:
> [DSN]
> Description = UserDSN connection to DB
> Driver = MSSQL
> Servername = MSSQL
> Database = database
> UID = 'username'
> PWD = 'password'
> Port = 1433
>
> and it works like a charm...consequently, if I remove the
> username/password information from the perl script or the .odbc.ini
> file it won't work (it aparently has to be in both places).
>
> Thanks for the suggestions.
>
> Steve
>
> On Sun, 5 Dec 2004 23:32:47 -0500, Steve Hoffman <srhoffman at gmail.com> wrote:
> > Anyone here have any luck connecting perl to MSSQL from Linux? I've
> > installed the following:
> > unixODBC
> > freeTDS
> > DBD:ODBC
> >
> > and configured everything as best I could, but I can't get it to
> > connect...always get an error:
> >
> > DBI connect('DSN','username',...) failed: [unixODBC][FreeTDS][SQL
> > Server]Unable to connect to data source (SQL-08001)(DBD:
> > db_login/SQLConnect err=-1) at ./testSQL line 6
> >
> > and the script I'm running to test is below
> >
> > #!/usr/bin/perl
> > #
> > use strict;
> > use DBI;
> >
> > my $dbh = DBI->connect('dbi:ODBC:DSN', 'username', 'password');
> > $dbh->disconnect if ($dbh);
> >
> > the DSN you see in the error and the script is actually the DSN the
> > ~/.odbc.ini file:
> > [DSN]
> > Driver = MSSQL
> > Description = Database
> > Trace = No
> > Server = SQL2K #from /etc/freetds.conf
> > Database = database
> >
> > the freetds.conf entry:
> > # A typical Microsoft SQL Server 2000 configuration
> > [SQL2K]
> > host = dbserv.domain.com
> > port = 1433
> > tds version = 8.0
> >
> > and the odbcinst.ini:
> > [MSSQL]
> > Description = Connection to MSSQL Database
> > Driver = /usr/lib/libtdsodbc.so
> > FileUsage = 1
> >
> > switching database servers isn't an option...half my company has their
> > lips firmly planted on the microsoft tit (or is it teet?). I
> > basically just need to get this working... Anyone who's done this care
> > to share any words of wisdom?
> >
> > Thanks as usual!
> > Steve
> >
> --
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc
>
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com
More information about the TriLUG
mailing list