j.goor has asked for the wisdom of the Perl Monks concerning the following question:
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 "Crea +teObject: $!"; $conn->Open("<some DSN to a MSSQL database>"); 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 e +rrorchecking 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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Help needed on OO module
by pelagic (Priest) on Jan 10, 2005 at 11:49 UTC | |
by j.goor (Acolyte) on Jan 10, 2005 at 13:20 UTC | |
by pelagic (Priest) on Jan 10, 2005 at 14:16 UTC |