> DM.Tpagares is a TMSTable, the last 3 lines of the code, sometimes work
> sometimes dont... i check it evaluating DM.Tpagares.RecordCount.
What MyDAC version do you use? Version 4.00.0.1 had an error that can cause similar problems.
Try to shorten your example and set Q.Debug := True to see a query passed to the server.