Monks,
I'm currently developing a Perl/CGI app that uses an MS Access database. To connect to the database, I'm using the Win32::ODBC module (I'd rather use DBI, but right now I must use Win32::ODBC).

The problem:
The app breaks when I send an SQL statement to the database and it returns more than 246 records. No error message is sent out.

The Code:

my $sqlStatement = "SELECT * FROM databaseName ORDER BY ID"; # Making the database connection my $dbh = new Win32::ODBC("User") or die "Couldn't connect to database: " . DBI->errorstr; if ($dbh->Sql($sqlStatement)){ print "SQL failed!.\n"; print "Error: " . $dbh->Error() . "\n"; $dbh->Close(); exit; } my @dates = (); my %Data = (); # Loop through the recordset, put the data into our array, then do wit +h it as we please while( $dbh->FetchRow() ) { %Data = $dbh->DataHash(); push( @dates, $Data{myDateTime} ); } # Say goodbye to the database $dbh->Close();

What I have tried:

  1. Using this select statement works: "SELECT TOP 246 datetime FROM myDatabaseName ORDER BY ID".
  2. Taking %Data = $dbh->DataHash(); out of the while( $dbh->FetchRow() ){} loop works unless I call FetchRow more than 246 times.
  3. I've tried raising the maximum buffer size $dbh->SetMaxBufSize(3024000); with no success.
  4. If I neglect to call %Data = $dbh->DataHash(); then the while loop iterates the correct number of times.

Where I think the problem could lie:

  1. My own mistake that someone can hopefully point out
  2. A Win32::ODBC bug
  3. An MS Access bug
  4. A server setting preventing large database queries
  5. An MS Access setting preventing large database queries
Any help would be greatly appreciated.

-----------------------------------
Washizu
http://www.bengarvey.com

Corrected sql per author's req. - dvergin 2002-08-31


In reply to MS Access and Win32::ODBC problem by Washizu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.