http://qs321.pair.com?node_id=371650

skyler has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks, I need your help. I'm trying to connect to a SQL Server 2000 database and I'm having problems with it. when I run the script, it gets an error message "Can't locate method "Connect" via package "DBI" Perhaps you forgot to load DBI at line 39" Could you let me know what is it wrong in the script?? Could you give me an example how to connect to SQL Serve 2000 using DBI?? I'll appreciate your help.
#! perl -w use strict; use warnings; use DBI; # my $dir = 'K:\\reports'; # my $count = 0; # opendir DH, $dir or die "Cannot open $dir: $!"; # while (my $file = readdir DH) { # next unless $file =~ /\.pdf$/; # my @newfile = substr($file,2,6); # process_records(@newfile); # } # closedir DH; my $user = "username"; my $password = "password1"; my $data_source = "dbi::SQL Server:Interfaces"; my $dbh = DBI->connect($data_source, $user, $password, { PrintError => 1, RaiseError => 0 } ) or die "Can't connect to $data_source: $DBI::errstr"; my $sth = $dbh->prepare( q{ SELECT * FROM tableview where field1 = '029622'}) or die "Can't prepare statement: $ +DBI::errstr"; my $rc = $sth->execute or die "Can't execute statement: $DBI::errstr"; print "Field names: @{ $sth->{NAME} }\n"; while (my @arr = $sth->fetchrow_array) { print "@arr\n"; } die $sth->errstr if $sth->err; $dbh->disconnect;