Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Perl-odbc

by Big K (Monk)
on Jul 18, 2001 at 20:56 UTC ( [id://97761]=note: print w/replies, xml ) Need Help??


in reply to Perl-odbc

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://97761]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-03-29 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found