mnooning has asked for the wisdom of the Perl Monks concerning the following question:
I have tried many versions of the six lines of code pasted further below, and I keep getting the same error messages. I am pasting two such occurrances further below. The end goal is to be on a Linux box - CentOS - and connect to a remote Microsoft SQL Server 2000 on a Windows machine. I am told by the sysadmin that the ODBC drivers are okay on the Windows machine, and noted that people in the Windows world connect with it just fine.
In the code pasted below, the names Server05, Payroll and JohnSmith, the ip address, etcetera are of course substitutions for the real names.
I have also tried setting these three env vars:According to the info below, I have unixODBC and DBD:ODBC installed.$ENV{DBI_DSN} = 'dbi:ODBC:SQL Server'; $ENV{DBI_USER} = 'JohnSmith'; $ENV{DBI_PASS}='Hello';
I cannot figure out what I am doing wrong. Can you spot anything?------------ >odbcinst --version unixODBC 2.2.11 ------- >perl -MDBI -e 'DBI-> installed_versions;' Perl : 5.008008 (i386-linux-thread-multi) -> I really ha +ve 5.8.8 OS : linux (2.6.9-42.0.3.elsmp) DBI : 1.604 DBD::Sponge : 12.010002 DBD::Proxy : 0.2004 DBD::ODBC : 1.15 DBD::Gofer : 0.010103 DBD::File : 0.35 DBD::ExampleP : 12.010007 DBD::DBM : 0.03 >odbcinst -j unixODBC 2.2.11 DRIVERS............: /etc/odbcinst.ini SYSTEM DATA SOURCES: /etc/odbc.ini USER DATA SOURCES..: /root/.odbc.ini >odbcinst -q -d [SQL Server] [PostgreSQL]
----------------------- Paste code example 1 #!/usr/bin/perl -w use strict; use DBI; use DBD::ODBC; my $DSN = 'driver={SQL Server};Server=Server05;database=Payroll;uid=Jo +hnSmith;' my $dbh = DBI->connect("dbi:ODBC:$DSN") or die "$DBI::errstr\n"; ---------------------- End Paste code example 1
---------------------- Paste error message example 1 DBI connect('driver={SQL Server};Server=Fridge;database=Payroll;uid=Jo +hnSmith;','',...) failed: [unixODBC][Driver Manager]Data source name +not found, and no default driver specified (SQL-IM002) at a1.pl line +9 [unixODBC][Driver Manager]Data source name not found, and no default d +river specified (SQL-IM002) ---------------------- End Paste error message example 1
----------------------- Paste code example 2 #!/usr/bin/perl -w use strict; use DBI; use DBD::ODBC; my $DSN = 'driver={SQL Server};Server=10.0.0.53:1433;Database=Payroll; +Uid=JohnSmith;Pwd=Hello;'; my $dbh = DBI->connect("dbi:ODBC:$DSN") or die ($DBI::errstr . "\n"); ---------------------- End Paste code example 2
---------------------- Paste error message example 2 DBI connect('driver={SQL Server};Server=10.0.0.53:1433;Database=Payrol +l;Uid=JohnSmith;Pwd=Hello;','',...) failed: [unixODBC][Driver Manager +]Data source name not found, and no default driver specified (SQL-IM0 +02) at aa.pl line 6 [unixODBC][Driver Manager]Data source name not found, and no default d +river specified (SQL-IM002) ---------------------- Paste error message example 2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI Connect SQL Server SQL-IM002
by pileofrogs (Priest) on May 16, 2008 at 16:42 UTC |