| Refresh | Home EGTry.com

simple example to access database using ODBC api


use strict;
use Win32::ODBC;


my $db=new Win32::ODBC("DSN=TDW Production; UID=xxxxxx; PWD=yyyyyyy")
  or die Win32::ODBC::Error();


if ($db->Sql("select current_date")) {
  print "SQL Error: " . $db->Error() . "\n";
  $db->Close();
  exit;
}


while($db->FetchRow) {
  my ($date)=$db->Data();
  print "Date $date\n";
}


$db->Close();