Jack,
Just as an extra check. What do you get if you fully qualify the DSN in the
dbi connect string?
(that is, a DSN'less connection) ie "dbi:ODBC:driver= 'etc'"
Neil
> -----Original Message-----
> From: Jack McKinney [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 10, 2001 6:12 AM
> To: [EMAIL PROTECTED]
> Subject: DBI:ODBC connects, but queries fail.
>
>
> The end result I need is that I need to be able to
> connect to a MSSQL
> server on a WinNT box from perl on my linux box. If someone
> can help me
> make this happen, I'll buy you lunch (if you aren't in
> Austin, TX, I'll
> send you a gift certificate). Here is what I currently have:
>
> I have installed unixodbc 2.0.6 and freetds 0.50 on my
> linux 2.2.17
> system. I have created the following entry in
> /usr/local/etc/odbc.ini:
>
> [TEST]
> Driver=/usr/local/lib/odbc-i02.so
> Server=mssql.mydomain.com
> User=myuser
> Pass=mypass
> Database=testdb
> Majorver=4
> Minorver=2
> ConnectTimeout=30
> Trace=Yes
> TraceFile=/tmp/odbc-mssql
>
>
> If I run 'isql TEST' from the command line (isql is a
> command line
> sql interpreter that comes with unixodbc), I am able to issue queries
> and get correct response from the MSSQL server at mssql.mydomain.com.
> THIS MEANS THAT MY ODBC IS INSTALLED CORRECTLY!
>
> The entry above logs to /tmp/odbc-mssql. If I run the
> isql command,
> issue one query, and then exit, this file contains:
>
> [Inline TDS
> Driver][/development/src/odbc/SQLConnect.c][/development/src/o
> dbc/SQLConnect.c][89]SQL_SUCCESS
> [Inline TDS
> Driver][/development/src/odbc/SQLGetInfo.c][/development/src/o
> dbc/SQLGetInfo.c][12]handle = $0804FA58
> [Inline TDS
> Driver][/development/src/odbc/SQLAllocStmt.c][/development/src
> /odbc/SQLAllocStmt.c][15]handle = $0804FA58
> [Inline TDS
> Driver][/development/src/odbc/SQLDisconnect.c][/development/sr
> c/odbc/SQLDisconnect.c][7]handle = $0804FA58
>
> So, I am ready for ODBC for perl. I install ODBC 0.28,
> and run the
> following script (the query is the same one I executed from isql):
>
> #!/usr/bin/perl
>
> use DBI;
>
> $query = "SELECT acctid,company FROM account";
>
> #DBI->trace;
> $db = DBI->connect("DBI:ODBC:TRACK") or die $DBI::errstr;
>
> $h = $db->prepare($query);
> $h->execute;
> $save = $count = $h->rows;
> while($count > 0)
> {
> @row = $h->fetchrow;
> $row = join("|",@row);
> print "$row\n";
> }
> $h->finish;
> $db->disconnect;
>
> I get the following error:
>
> DBD::ODBC::st execute failed: [unixODBC][Driver Manager]Data
> source name not found, and no default driver specified
> (SQL-IM002)(DBD: describe/SQLColAttributes/SQL_COLUMN_LENGTH
> err=-1) at ./test2.pl line 11.
> DBD::ODBC::db disconnect failed: (DBD:
> db_disconnect/SQLDisconnect err=-1) at ./test2.pl line 20.
>
>
> It claims that it could not find the DSN. Several points:
>
> 1. I removed /tmp/odbc-mssql before running this script.
> This file is back,
> which indicates to me that it _is_ finding the DSN. How else
> would it know
> where to write the trace?
> /tmp/odbc-mssql:
>
>
> [Inline TDS
> Driver][/development/src/odbc/SQLConnect.c][/development/src/o
> dbc/SQLConnect.c][89]SQL_SUCCESS
> [Inline TDS
> Driver][/development/src/odbc/SQLGetInfo.c][/development/src/o
> dbc/SQLGetInfo.c][12]handle = $08181E28
> [Inline TDS
> Driver][/development/src/odbc/SQLSetConnectOption.c][/developm
> ent/src/odbc/SQLSetConnectOption.c][10]handle = $08181E28
> [Inline TDS
> Driver][/development/src/odbc/SQLEndTran.c][/development/src/o
> dbc/SQLEndTran.c][43]SQL_SUCCESS
> [Inline TDS
> Driver][/development/src/odbc/SQLSetConnectOption.c][/developm
> ent/src/odbc/SQLSetConnectOption.c][58]SQL_SUCCESS
> [Inline TDS
> Driver][/development/src/odbc/SQLSetConnectOption.c][/developm
> ent/src/odbc/SQLSetConnectOption.c][10]handle = $08181E28
> [Inline TDS
> Driver][/development/src/odbc/SQLSetConnectOption.c][/developm
> ent/src/odbc/SQLSetConnectOption.c][58]SQL_SUCCESS
> [Inline TDS
> Driver][/development/src/odbc/SQLAllocStmt.c][/development/src
> /odbc/SQLAllocStmt.c][15]handle = $08181E28
> [Inline TDS
> Driver][/development/src/odbc/SQLDisconnect.c][/development/sr
> c/odbc/SQLDisconnect.c][7]handle = $08181E28
> [Inline TDS
> Driver][/development/src/odbc/SQLDisconnect.c][/development/sr
> c/odbc/SQLDisconnect.c][14]SQL_ERROR Active Statements exist.
> Can not disconnect.
>
> 2. If it could not find the DSN, why did the ODBC manager
> report so many
> successful lines?
>
> 3. If it could not find the DSN, then why did ODBC fail on
> the handle->execute
> instead of the DBI->connect? I do check the return of
> DBI->connect, after all.
>
> I have tried many variations including setting ODBCHOME
> and DBI_DSN in
> the environment, but always have basically the same problem.
>
> --
> "There is no hook, my friend. Jack McKinney
> There is only what we do." [EMAIL PROTECTED]
> -Doc Holiday, Wyatt Earp (1994) http://www.lorentz.com
> 1024D/D68F2C07 4096g/38AEF076
>
__________________________________________________________________________
Please Note :
Only the intended recipient is authorised to access or use this e-mail. If
you are not the intended recipient,
please delete this e-mail and notify the sender immediately. The contents
of this e-mail are the writer's
opinion and are not necessarily endorsed by the Gunz Companies unless
expressly stated.
We use virus scanning software but exclude all liability for viruses or
similar in any attachment.