Quick DBI:ODBC question...

From: John W. Herbold (JWHERBOLD_at_arkbluecross.com)
Date: 01/20/04


To: dbi-users@perl.org
Date: Tue, 20 Jan 2004 10:50:53 -0600

I am trying to hit a MS SQL server using DBI:ODBC from an win2k box. I have
the odbc client setup on my box, but I can not get the perl to hit it. Any
help would be great! I use DB2 with no problem and am trying the MSSQL
world (not by choice ;-). Here is what I am trying to run...

# I have the odbc connection setup as "MSSQL"

     my $dbh = DBI->connect('dbi:ODBC:database=MSSQL',
'jwherbol','ttt55ttt'); if ($DBI::errstr) {print $DBI::errstr;}
     print "Connection to DB returned: $DBI::errstr\n";
     my $sql = qq|select count(*) from IISLog|;
     my $sth = $dbh->prepare($sql);
     print "Prepare on SQL code returned: $DBI::errstr\n";
     my $rc = $sth->execute;
     print "Execute to DB returned $rc\n";
     while (($T1) = $sth->fetchrow_array() ) {
        print "SQL Query returned $T1\n";
     }
     $dbh->disconnect;

Thanks!

John W. Herbold Jr.