Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Posts
    20

    Unanswered: 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];
    }

    };

  2. #2
    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

  3. #3
    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.

  4. #4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •