drodinthe559 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use Win32::ODBC; my $DSN = "DSN=DATABASE1;UID=sa;PWD=password;"; my $connection = new Win32::ODBC("$DSN"); if (!$connection){die "Could not open connection to DSN because of [$! +]";} my $SQL = "SELECT Field1, Field2 FROM table1"; if ($connection->Sql($SQL)) { print "SQL failed.\n"; print "Error: " . $connection->Error() . "\n"; print $connection->Error() . "\n"; $connection->Close(); die;} #Report header. print "Field 1" . "\t\t\t" . "Field 2" . "\n"; while ($connection->FetchRow()) { my %dataRow =$connection->DataHash(); print $dataRow{field1} . "\t\t" . $dataRow{field2} . "\n";} $connection->Close(); my $DSN2 = "DSN=DATABASE2;UID=sa;PWD=password;"; my $connection2 = new Win32::ODBC("$DSN"); if (!$connection2){die "Could not open connection to DSN because of [$ +!]";} my $SQL2 = "SELECT * FROM TABLE2"; if ($connection2->Sql($SQL2)) { print "SQL failed.\n"; print "Error: " . $connection->Error() . "\n"; print $connection->Error() . "\n"; $connection->Close(); die;} while ($connection2->FetchRow()) { my %dataRow2 =$connection2->DataHash(); print $dataRow2{field1} . "\t\t" . $dataRow2{field2} . "\n";} $connection->Close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Two ODBC Connections
by olus (Curate) on Aug 18, 2008 at 23:22 UTC | |
|
Re: Two ODBC Connections
by Skeeve (Parson) on Aug 19, 2008 at 08:56 UTC | |
|
Re: Two ODBC Connections
by gone2015 (Deacon) on Aug 19, 2008 at 09:22 UTC | |
|
Re: Two ODBC Connections
by apl (Monsignor) on Aug 19, 2008 at 11:29 UTC | |
|
Re: Two ODBC Connections
by pajout (Curate) on Aug 19, 2008 at 13:59 UTC |