Anonymous Monk, I have put together a small search engine using ODBC, but I didn't use a hash to store my results. I embeded & called my
SELECT, generating all the html within a
while loop. Here is a stripped down version of what I used.
use DBI;
# Connect to the database
my $DSN = 'driver=Microsoft Access Driver (*.mdb);dbq=database1.mdb';
my $dbh = DBI->connect("dbi:ODBC:$DSN") || die "Couldn't open database
+: $DBI::errstr;";
# Build a query
my $SQL1 = $dbh->prepare(<<End_SQL) || die "Couldnt prepare statement:
+ $DBI::errstr;";
select NAME_FIELD, TITLE_FIELD, EMAIL_FIELD FROM TBL_PEOPLE WHERE (TIT
+LE LIKE 'monk') ORDER BY NAME
End_SQL
# Execute the query
$SQL1->execute() || die "Couldn't execute statement: $DBI::errstr; sto
+pped";
while ( my ($resultField1, $resultField2, $resultField3) = $SQL1->fetc
+hrow_array() ) {
# perform any formatting/storage/etc with each record
}
# Disconnect from the database
$dbh->disconnect();
The fields which stored the information from
$SQL1->fetchrow_array() must coincide both in the number and order of the fields mentioned at the start of the
SELECT statement.
-
Big K