CarlosSanchez
12-16-2002, 10:27 PM
I'm trying to do this problem: Create a perl program that reads in information from the "cartable" table of the Access database file. We will use the SQL query string "SELECT * FROM cartable".
Assign that string to a variable. Create a connection to the database "cars.mdb" using the ODBC DBD and the "cars" DSN.
Print out a header saying that this is the Automobile database, and putting headers on the columns (ID, Year, Make, Model, Color, Price).
Prepare the SQL statement based on our earlier string. Execute the query.
Create a while {} loop to display the result set.
Here's what I have so far:
$db = DBI -> connect("dbi:ODBC:cars") || die "Couldn't open DB";
$st = $db -> prepare ("SELECT * FROM cartable");
while (@row = $st -> fetchrow_array)
{
print "$row[2]\n";
}
$db -> disconnect;
My question in, How would I print the title and header? Any help is appreciated. Thanks!
Assign that string to a variable. Create a connection to the database "cars.mdb" using the ODBC DBD and the "cars" DSN.
Print out a header saying that this is the Automobile database, and putting headers on the columns (ID, Year, Make, Model, Color, Price).
Prepare the SQL statement based on our earlier string. Execute the query.
Create a while {} loop to display the result set.
Here's what I have so far:
$db = DBI -> connect("dbi:ODBC:cars") || die "Couldn't open DB";
$st = $db -> prepare ("SELECT * FROM cartable");
while (@row = $st -> fetchrow_array)
{
print "$row[2]\n";
}
$db -> disconnect;
My question in, How would I print the title and header? Any help is appreciated. Thanks!