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]
|
|
|
| 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;
| |
|
|
|
|
|