in reply to Re^3: Sybase(on WinXPProfessional) connectivity with Perl(Sybase 15, Perl5.8.8)
in thread Sybase(on WinXPProfessional) connectivity with Perl(Sybase 15, Perl5.8.8)
use Win32::ODBC; my $DSN = "MSSQLpubsDSN"; my $connection = new Win32::ODBC($DSN); ## Check to make sure the connection is valid if (!$connection) { die "Could not open connection to DSN because of [$!]"; } my $SQL = "SELECT * FROM authors"; if($connection->Sql($SQL)) { print "I could not execute the following statement:\n $SQL\n"; print "I encountered this error:\n"; print $connection->Error() . "\n"; ## Closing the database connection $connection->Close(); ## Exiting the program die; } print "The query returns the following list of authors:\n"; while ($connection->FetchRow()) { my %dataRow = $connection->DataHash(); print $dataRow{au_id} . " : " . $dataRow{au_lname} . "\n"; } ## Closing the database connection $connection->Close();
Edit: g0n - code tags
|
|---|