Dear Monks,
The following code produces the following report. Any explanations?
#! perl -w scipt
use strict;
use DBI;
use DBD::ODBC;
my ( $data_source, $database, $user_id, $password ) = qw( matt First_t
+rial matt gold );
my $conn_string = "driver={SQL Server};Server=$data_source;Database=$d
+atabase;UID=$user_id;PWD=$password";
my $dbh = DBI->connect( "DBI:ODBC:$conn_string" ) or die $DBI::errstr;
my $sql = "SELECT * FROM Doncaster_1975_onwards LIMIT 100";
my $sth = $dbh->prepare( $sql );
$sth->execute;
my $out = "out_connection.txt";
open (OUT, "$out");
while ( my $result = $sth->fetchrow_hashref ) {
# Your fields can be accessed through the $result hashref, for exa
+mple:
print OUT "$result\n";
}
$dbh->disconnect;
C:\Documents and Settings\MattR\2003\Perl\November\5_12_04>perl Data_A
+.pl
DBI connect('driver={SQL Server};Server=matt;Database=First_trial;UID=
+matt
;PWD=gold','',...) failed: [Microsoft][ODBC SQL Server Driver][Named P
+ipes]S
pecified SQL server not found. (SQL-08001)
[Microsoft][ODBC SQL Server Driver][Named Pipes]ConnectionOpen (Create
+File()). (
SQL-01000)(DBD: db_login/SQLConnect err=-1) at Data_A.pl line 15
[Microsoft][ODBC SQL Server Driver][Named Pipes]Specified SQL server n
+ot found.
(SQL-08001)
[Microsoft][ODBC SQL Server Driver][Named Pipes]ConnectionOpen (Create
+File()). (
SQL-01000)(DBD: db_login/SQLConnect err=-1) at Data_A.pl line 15.
-
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.
|