Created
April 14, 2011 07:40
-
-
Save wose/919078 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
#use Parallel::ForkManager; | |
use DBI; | |
#use Win32::OLE; | |
my $dbh = DBI->connect("dbi:ODBC:driver={SQL Server};server=RAPTOR\\SQLEXPRESS;uid=;pwd=;database=perltest") or die "\n\nthe mssql connection died with the following error: \n\n$DBI::errstr\n\n"; | |
$dbh->{RaiseError} = 1; | |
if (defined($dbh)) | |
{ | |
print "Connected\n"; | |
my ($id, $col1, $col2); | |
my $SQL= "SELECT id, col1, col2 FROM foobar"; | |
my $Select = $dbh->prepare($SQL) or die "bad prepare"; | |
$Select->execute() or die "failed execution"; | |
$Select->bind_columns(\$id, \$col1, \$col2); | |
while($Select->fetch()) { | |
print "$id, $col1, $col2 <br />"; | |
} | |
$dbh->disconnect; | |
} | |
else | |
{ | |
print "Error connecting to database: Error $DBI::err - $DBI::errstr\n"; | |
} | |
#PS D:\t> perl .\perltest.pl | |
#Connected | |
#1, moo, kooh <br />2, baz, bar <br />PS D:\t> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment