Querying an ODBC database.


#!perl use Win32::ODBC; use CGI qw( :standard ); $queryString = param( "QUERY" ); $dataSourceName = "Products"; print header, start_html( "Search Results" ); if ( !( $data = new Win32::ODBC( $dataSourceName ) ) ) { print "Error connecting to $dataSourceName: "; print Win32::ODBC::Error(); exit; } if ( $data->Sql( $queryString ) ) { print "SQL failed. Error: ", $data->Error(); $data->Close(); exit; } print "Search Results"; print ""; for ( $counter = 0; $data->FetchRow(); $counter++ ) { %rowHash = $data->DataHash(); print < End_Row } print <
Your search yielded $counter results.

Please email comments to Associates, Inc.. End_Results print end_html; $data->Close();
$rowHash{'ID'} $rowHash{'FirstName'} $rowHash{'LastName'} $rowHash{'Phone'}