So....

I compiled FreeTDS from souce.

tsql - The FreeTDS utility connects okay.

unixODBC would not compile so I am using iODBC

DBD::Sybase compiles lovely and gives the following error if used:

[EMAIL PROTECTED] joelonx]# perl -w
use DBD::Sybase;
Can't load '/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/auto/DBD/Sybase/Sybase.so' for module DBD::Sybase: /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/auto/DBD/Sybase/Sybase.so: undefined symbol: bsd_tcp at /usr/lib/perl5/5.8.0/i386-linux-thread-multi/DynaLoader.pm line 229.
at - line 1
Compilation failed in require at - line 1.
BEGIN failed--compilation aborted at - line 1.


So I am using DBD::ODBC

My odbc.ini is:

;
;  odbc.ini
;
[ODBC Data Sources]
FreeTDS = FreeTDS

[OpenLink]
Driver          = /usr/local/lib/libtdsodbc.so
Description     = MS SQL Driver
Host            = 192.168.100.2
ServerType      = MSSQL
FetchBufferSize = 99
UserName        = ss_userid
Password        = ss_userid
Database        = UCP_SUB
ServerOptions   =
ConnectOptions  =
Options         =
ReadOnly        = no

[Default]
Driver = /home/local/lib/libtdsodbc.so


My odbcinst.ini is:

# Example driver definitinions
#
#
[FreeTDS]
Description     = ODBC for SQLServer
Driver          = /usr/lib/libtdsodbc.so
Setup           = /usr/lib/libtdsodbc.so.1
FileUsage       = 1


My perl script:

#!/usr/bin/perl

use DBI;
use DBD::ODBC;

my $DSN = 'dbi:ODBC:FreeTDS:192.168.100.2:UCP_SUB:ss_username:ss_username';
my $dbh = DBI->connect("dbi:ODBC:$DSN") or die "$DBI::errstr\n";

And the command line:

[EMAIL PROTECTED] joelonx]# perl -w dumpy.pl
DBI connect('dbi:ODBC:FreeTDS:192.168.100.2:UCP_SUB:ss_username:ss_username','',...) failed: [iODBC][Driver Manager]Data source name not found and no default driver specified. Driver could not be loaded (SQL-IM002)(DBD: db_login/SQLConnect err=-1) at dumpy.pl line 8
[iODBC][Driver Manager]Data source name not found and no default driver specified. Driver could not be loaded (SQL-IM002)(DBD: db_login/SQLConnect err=-1)


Again...help!


On Thu, 19 Aug 2004, Jeff Urlwin wrote:


I tried the below on the RedHat box I am on and got a different error:

DBI connect('driver={SQL
Server};Server=ipaddress
;database=databasename','userid',...) failed:
[unixODBC][Driver Manager] Data source name not found, and no
default driver specified (SQL-IM002)(DBD: db_login/SQLConnect
err=-1) at
dump1.pl line 12

Now I am really lost.

That message is because unixODBC can't find a DSN or a "SQL Server" driver or a DSN.

Here's what I would suggest (you may have done some of this already):

        1) Test that freeTDS itself (without the ODBC layer) can connect to
the server.  I suggest you download the tarball and look at the
documentation, as I don't know what documentation comes with the RPMS.
There is a .freetds (or something similar) that I've had to use to get
connectivity.

        2) When you get freeTDS working, then test that freeTDS's ODBC part
is working.  I believe there are some ODBC tests in the freeTDS distro, but
it's been a while (you may need to setup a DSN for this).

        3) Then -- use unixODBC to setup a DSN and test with isql, which
comes with UnixODBC.

        4) From there, you should be able to connect to your DSN with
DBD::ODBC.

*** NOTE: You *may* have an easier time with DBD::Sybase when using FreeTDS.
***  The ODBC layer on top of FreeTDS is constantly evolving, so your
mileage may vary.



I am using:

Perl 5.8.0
DBD::ODBC 1.09
libiodbc-3.51.2-1

Be careful here. Iodbc and unixODBC are two different beasts that, generally do the same thing [provide an ODBC driver manager].

unixODBC-2.2.8-5
libiodbc-admin-3.51.2-1
libiodbc-devel-3.51.2-1
freetds-0.62.1-1
freetds-devel-0.62.1-1
freetds-unixodbc-0.62.1-1


my odbc.ini is:

[ODBC Data Sources]
MSSQL Server = SQLServer

Note, in connect above, you indicated SQL Server with a space and in this document, no space...

Jeff


[SQLServer] Driver = /usr/lib/libtdsodbc.so Description = MSSQL Server Host = 192.168.100.2 ServerType = MS SQL 7 FetchBufferSize = 99 UserName = ss_userid Password = ss_userid Database = UCP_SUB ServerOptions = ConnectOptions = Options = ReadOnly = no

[Default]
Driver = /usr/lib/libtdsodbc.so


my odbcinst.ini is:

[SQLServer]
Description     = ODBC for MS SQL Server
Driver          = /usr/lib/libtdsodbc.so
Setup           = /usr/lib/libtdsS.so.1
FileUsage       =1

# Included in the unixODBC package
#[PostgreSQL]
#Description    = ODBC for PostgreSQL
#Driver         = /usr/lib/libodbcpsql.so
#Setup          = /usr/lib/libodbcpsqlS.so
#FileUsage      = 1


# Driver from the MyODBC package # Setup from the unixODBC package #[MySQL] #Description = ODBC for MySQL #Driver = /usr/lib/libmyodbc.so #Setup = /usr/lib/libodbcmyS.so #FileUsage = 1


I am still horribly lost.




On Wed, 18 Aug 2004, amonotod wrote:

From: Joel West <[EMAIL PROTECTED]>
Date: 2004/08/18 Wed PM 05:33:54 GMT

my $dsn = "DBI:ODBC:databasename:ipaddress";

(Assuming you're on Windows...) my $dsn = "DBI:ODBC:driver={SQL Server};Server=ipaddress;database=databasename;";

Joel (Yossel) West

HTH, amonotod


--

   `\|||/         amonotod@    | sun|perl|windows
     (@@)         charter.net  | sysadmin|dba
 ooO_(_)_Ooo____________________________________
 _____|_____|_____|_____|_____|_____|_____|_____|




Reply via email to