Not exactly the answer to your question, but here is some concept code I left in my temp directory which might help.
#/usr/bin/perl -w
use strict;
use DBI;
my $DSN = 'dbi:ODBC:driver={SQL Server};server={myserver};database={my
+db}';
my $dbh = DBI->connect($DSN, undef, undef) or die "$DBI::errstr\n";
my $gSQLCmd = 'SELECT col1, col2, col3 FROM mytable';
my $gSQLHandle = $dbh->prepare
(
$gSQLCmd
) || die 'Error with SQL statement ['.$DBI::errstr.' - '.$DBI::err.'
+]';
$gSQLHandle->execute() || die 'Error with SQL statement ['.$DBI::errst
+r.' - '.$DBI::err.']';
while (my @gFields = $gSQLHandle->fetchrow_array)
{
print 'Row: ',$gFields[0],"\t",$gFields[1],"\t",$gFields[2],"\n";
}
$dbh->disconnect;
The code will work a little better if you replace myserver, mydb, and mytable with ones from your actual system. *Smiles* Also, please note that this code connects to the database without a userid or password -- it is using my domain account for authorization.
Update I forgot to give credit where credit is due -- my code is based on the information from DBD::ODBC Connecting without DSN from Win32 by sparkyichi
-
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.