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;

In reply to Cannot connect to SQL Server 2000 using DBI by skyler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.