For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > May 2004 > Simple DB connect









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Simple DB connect
JRMc

2004-05-17, 7:30 pm

I have a data source I can open with Query Analyzer and I can't open
it with Perl. Any help would be GREATLY appreciated!

In Query analyzer:
SQL Name: abc
Login: def
Pwd: ghi

my database is available at: jkl
and I want to see rows from table: mno

mycode.pl code:
#------------------------------------------------------------------------------

use DBI;

$username = 'def';
$password = 'ghi';
$database = 'jkl';
$hostname = 'abc';

my $dsn = 'DBI:ODBC:database='.$database.';hostname='.$hostname.';';
print $dsn ;
$dbh = DBI->connect($dsn, $username, $password);

$SQL= "select * from mno";

$Select = $dbh->prepare($SQL);
$Select->execute();

while($Row=$Select->fetchrow_hashref)
{
print "$Row->{UsrID} $Row->{Transaction}";
}
#------------------------------------------------------------------------------

The result:

DBI connect('database=jkl;hostname=abc;'def'
,'',...) failed: [Microsof
t][ODBC Driver Manager] Data source name not found and no default
driver specifi
ed (SQL-IM002)(DBD: db_login/SQLConnect err=-1) at mycode.pl line 12
Can't call method "prepare" on an undefined value at mycode.pl line
16.
DBI:ODBC:database=jkl;hostname=abc;
JRMc

2004-05-18, 10:32 am

OK... everyone together now....

READ THE F-ING FAQS!!!!

I found the answer at:
http://dev.isystek.com/dbi/fom-serve/cache/7.html

Sorry to bother....
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com