Using Fetchall and fetchrows
Posted: Sun 29 Mar 2009 06:13
OK, maybe this is a dumb question as I'm just getting up to speed on these components.
I need to retrieve a small number of records on each search as I could have potentially several hundred to a thousand or more for any given search match. I only need to look at them 20 or so at a time.
To test the fetchall=false for TMyquery I set fetchrows to 5 to make sure it was working, with display in a TDBGrid.
No matter what I set for FetchRows I get all the records that match the SQL search, not the first X records. That is I set it to 5, but the grid shows all the records that match, in this case 10 records.
Here's the SQL if that's relevant:
MyQuery1.Close;{close the query}
//assign new SQL expression
MyQuery1.SQL.Clear;
MyQuery1.SQL.Add ('Select *');
MyQuery1.SQL.Add ('FROM clients');
MyQuery1.SQL.Add ('WHERE last_name LIKE '''+SearchName.Text+'%''');
MyQuery1.Open;
Any ideas what stupid thing I'm doing wrong? Thanks in advance.
I need to retrieve a small number of records on each search as I could have potentially several hundred to a thousand or more for any given search match. I only need to look at them 20 or so at a time.
To test the fetchall=false for TMyquery I set fetchrows to 5 to make sure it was working, with display in a TDBGrid.
No matter what I set for FetchRows I get all the records that match the SQL search, not the first X records. That is I set it to 5, but the grid shows all the records that match, in this case 10 records.
Here's the SQL if that's relevant:
MyQuery1.Close;{close the query}
//assign new SQL expression
MyQuery1.SQL.Clear;
MyQuery1.SQL.Add ('Select *');
MyQuery1.SQL.Add ('FROM clients');
MyQuery1.SQL.Add ('WHERE last_name LIKE '''+SearchName.Text+'%''');
MyQuery1.Open;
Any ideas what stupid thing I'm doing wrong? Thanks in advance.