You may want to try RaiseError => 1 or even DBI->trace (before
connecting) to see if you are actually getting errors earlier on...  I
know you are able to connect via command-line but 'Data source name not
found...' is a pretty specific error, pointing to some configuration
problem with the DSN.

Jack McKinney wrote:
> 
> Big Brother tells me that paul wrote:
> > What's the error message?
> >
> 
> 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 ./ODBC/test2.pl line 19.
> DBD::ODBC::db disconnect failed: (DBD: db_disconnect/SQLDisconnect err=-1) at 
>./ODBC/test2.pl line 28.
> 
>     Yes, I am sure I am setting the DSN.  Below is the script I am using.
> Line 19 is the $h->execute line.  Line 28 is the $db->disconnect line. I
> am executing it as:
> 
> ./test.pl MSSQLTEST "SELECT testcol FROM testtab"
> 
>     This same query works from the command line when I type "isql MSSQLTEST"
> and then enter the query.  I get the expected 500 or so rows.
> 
> #!/usr/bin/perl
> 
> use DBI;
> 
> $dsn = shift;
> $query = shift;
> $dbd = "dbi:ODBC:$dsn";
> 
> print STDERR "Connecting to DSN $dsn\n";
> $db = DBI->connect($dbd);
> if(!defined $db)
>  {
>   print $DBI::errstr,"\n";
>   exit 1;
>  }
> print "Query: $query\n";
> 
> $h = $db->prepare($query);
> $h->execute;                                    # <-- Line 19
> $save = $count = $h->rows;
> while($count > 0)
>  {
>   @row = $h->fetchrow;
>   $row = join("|",@row);
>   print "$row\n";
>  }
> $h->finish;
> $db->disconnect;                                # <-- Line 28
> 
>   ------------------------------------------------------------------------
>    Part 1.2Type: application/pgp-signature

Reply via email to