Hello,

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:
$ENV{DBI_DSN} = 'dbi:ODBC:SQL Server'; $ENV{DBI_USER} = 'JohnSmith'; $ENV{DBI_PASS}='Hello';
According to the info below, I have unixODBC and DBD:ODBC installed.
------------ >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]
I cannot figure out what I am doing wrong. Can you spot anything?
----------------------- 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

In reply to DBI Connect SQL Server SQL-IM002 by mnooning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.