Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-24 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found