Access hangs at GetRows
Code that reads a linked table with Recordset.GetRows doesn't return; Access stops responding and
has to be ended. With MoveNext over the same table, error 3146 “ODBC–call failed” appears instead.
Environment
Access or DAO with linked tables, with any ODBC driver, including Microsoft ODBC Driver 18.
Cause
If a next page fails while reading further – for example because of the service's request limit
(429), a time limit, or a network interruption – the driver reports the error (SQL_ERROR).
GetRows then calls SQLFreeStmt(SQL_CLOSE) endlessly and never returns, regardless of the
SQLSTATE. With the SQL Server driver, it's the same, for example with a view that divides by zero in the
middle of reading. It's a behavior of DAO, not of the driver.
Resolution
Replace
GetRowswith a loop usingMoveNext:Do Until rs.EOF ' … process … rs.MoveNext LoopOn the same error,
MoveNextreturns immediately with 3146, and your error handling takes over.- Find the actual error while reading further with the trace. Against the data service, next pages don't count against the request limit; a
429while reading further points to self-built next-page addresses or a different service.
Verification
The same operation ends with an error message instead of hanging, or it runs through.