Hello community!
Specs:
Lazarus 1.1 (2012-05-11)
FPC 2.6.1 (SVN Rev. 37249)
Windows XP SP3
----
MySQL 5.1 on a Linux Server
--------------------------------------
Usually I make my filtering direct with SQL but I wanted to try the Filter property of TSQLQuery.
I made some search but I couldn't find an answer for my problem.
This is the problem: after applying a filter on a SQLQuery, if I scroll the DBGrid by grabbing the DBGrid scrollbar I get the following error: "SQLQueryMain : Could not find the requested record".
Many moons ago I said I'd create a test application that reproduces this issue. For ease of distribution, I created the test application using sqlite. The original poster saw this issue with MySQL & with SQLite. I've seen it with MS SQL (via ODBC (but you'll have to take my word for it, creating a test for MS SQL is useful only to people with SQL Server hanging around)) and now this test code reproduces the issue again with SQLite. However, before I dig further, or post on the bug tracker, could someone please confirm I'm not doing something stupid with filtering?
My filtering code is nothing more than...
procedure TForm1.btnFilterClick(Sender: TObject);
begin
If SQLQuery1.Active Then
Begin
SQLQuery1.Filtered:= False;
SQLQuery1.FilterOptions:=[];
SQLQuery1.Filter := 'Field2 < 500';
SQLQuery1.Filtered:= True;
end;
end;Here's the complete project, including pre-compiled exe (win 32) and sqllite3.dll. Run the exe. Press btnConnect once. Press btnAddRecords twice (each time adds 10,000 records). Press btnFilter. Try to scroll the DBGrid using the vertical scrollbar (grab the thumb, drag to a new position and let go.) Dragging may work a few times, but you'll eventually hit the problem (obviously when you finally end up on a record that the DBGrid thinks is still in the TDataset, but which the TDataset has filtered out). Exactly as the original poster reported.
Click here to download the project...http://db.tt/L9bzree8(
https://dl.dropboxusercontent.com/u/59503182/Lazarus/DBGrid%20Error/DBGrid_Error.7z for those who don't like shortened URLs)
The project was built using Lazarus 1.0.8/FPC 2.6.2. My SVN copy is 64 bit, and I couldn't find a 64bit sqlite.dll to connect with, so I was unable to test with latest...
Previously we got bogged down with assumptions it was RecordCount being wrong and other such. I'm no longer convinced. I think the OP and I are either using Filtering incorrectly, or that we do in fact have an issue with DBGrid.
Looking for the following assistance:
* Clarification .Filter is being used correctly...
* If .Filter is being used correctly, then testing with SVN Lazarus to see if the issue has since been solved.
Many thanks, and sincere apologies for taking OVER a year before I remembered to investigate this further... :-(
UPDATE: Oh, that's interesting.
The issue doesn't appear to occur until you first drag the scrollbar thumbnail right to the very end of the grid. Thereafter the issue occurs reasonably quickly....