This might get you jump started
# See http://perlmonks.org/index.pl?node_id=183417 package DBC; use DBI; my $dbh; sub new { return __PACKAGE__ } sub connect { my ($pointless, $details) = @_; my $server = $details->{server} || 'default_server'; my $database = $details->{database} || 'default_database'; my $user = $details->{user} || 'default_user'; my $password = $details->{password} || 'default_password'; my $DSN = "driver=\{SQL Server\}; Server=$server; database=$database; uid=$user; pwd=$password;"; $dbh ||= DBI->connect("dbi:ODBC:$DSN") or die "$DBI::errstr\n"; } 1;
And now, when you need connectivity -
use DBC; my $dbh = DBC->connect({ database => 'MyDB', user => 'me', password => 'psw' }); my $sql = qq{ select mycol, myothercol from mytable where myothercol = 'foo' }; my $qr = $dbh->selectall_arrayref($sql)
In reply to Re: Perl connect to Microsoft SQL 2000
by EdwardG
in thread Perl connect to Microsoft SQL 2000
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |