7.4.2. Win32::ODBC
The Win32::ODBC module was written by Dave Roth,
based on original code by Dan DeMaggio. It's a Perl extension
written in C++ and is closely associated with the Win32 platform.
The main goal of the Win32::ODBC module is to
provide direct access to the ODBC functions. From that point of view,
Win32::ODBC provides a fairly thin, low-level
interface.
Here's a sample of Win32::ODBC code:
use Win32::ODBC;
### Connect to a data source
$db = new Win32::ODBC("DSN=MyDataDSN;UID=me;PWD=secret")
or die Win32::ODBC::Error();
### Prepare and Execute a statement
if ($db->Sql("SELECT item, price FROM table")) {
print "SQL Error: " . $db->Error() . "\n";
$db->Close();
exit;
}
### Fetch row from data source
while ($db->FetchRow) {
my ($item, $price) = $db->Data(); ### Get data values from the row
print "Item $item = $price\n";
}
### Disconnect
$db->Close();