If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > Perl DBI and ODBC

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-21-05, 21:07
sam888 sam888 is offline
Registered User
 
Join Date: Dec 2004
Posts: 20
Perl DBI and ODBC

Hi, Please help ! I am new to perl and I am testing if perl can connect to a MS Access97 database and retrive some records. The following is the line inside an eval code block: it runs but no result. I don't know if the database can be open. why there is no error message? (All the variables are properly declared and contain valid value)

eval {
$dbh = DBI->connect($dsn,$user,$pswrd,$driver,{RaiseError=>1} ) or die "Database

connection not made: $DBI::errstr";

print "Inside eval, dbh=$dbh";
$sth = $dbh->prepare($sql);
$sth->execute();
while (my @rs = $sth->fetchrow())
{
print rs[0];
}

};
Reply With Quote
  #2 (permalink)  
Old 09-22-05, 08:48
sam888 sam888 is offline
Registered User
 
Join Date: Dec 2004
Posts: 20
I moved this line outside the eval, then I got :
Software error:
DBI connect('factory','admin',...) failed: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1) at F:\ButtonS\test2.pl line 68
Reply With Quote
  #3 (permalink)  
Old 09-22-05, 13:22
sam888 sam888 is offline
Registered User
 
Join Date: Dec 2004
Posts: 20
OK. The database can be opened, if print out the handle of the db and st as well. but @rs received nothing. It seems that @rs=sth->fetchrow() did not return anything. any idea? please help.
Reply With Quote
  #4 (permalink)  
Old 09-22-05, 14:19
sam888 sam888 is offline
Registered User
 
Join Date: Dec 2004
Posts: 20
I am now able to retrieve records. but How to read a specific record?
The statemen select refno where refno=$refno does not work for me. Even after I got rid of the trailing spaces. I wonder why.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On