package Database; use 5.008; use strict; use warnings; use Win32::OLE::Variant; # For timestamp readings use Win32::ADO qw/CheckDBErrors/; # For ADO errorchecking use base 'Win32::OLE'; # Inherit from 'Win32::OLE' our $VERSION = '0.01'; # Local functions sub _dbconnect { # Create database connection my $conn = CreateObject Win32::OLE "ADODB.Connection" || die "CreateObject: $!"; $conn->Open(""); return $conn; } # Constructor sub new { my $class = shift; ( bless {}, $class )->_init( {@_} ); } sub _init($) { my ($self, $args) = @_; $self->{_dbh} = _dbconnect(); $self; } # This method should replace the Win32::OLE 'Execute' method and add errorchecking to it. (doesn't work now!) sub Execute { my ($self, $sql) = shift; my $rs = $self->{_dbh}->Execute($sql); my @dberrors = (); CheckDBErrors($self->{_dbh}, \@dberrors) or croak "SQL Failed at ", __LINE__, "\n", @dberrors; return ($rs); } 1;