Solved

TSQLQuery.FindFirst

Posted on 2001-08-20
4
277 Views
Last Modified: 2010-04-04
Hi.

I know this is a silly question, but it's really bugging me.  I'm having a problem with FindFirst when used with a TSQLQuery (Delphi 6).  It just doesn't want to work.

Here's some code....

  EAQuery.SQL.Clear;
  EAQuery.SQL.Add('select * from CONTACT');
  EAQuery.Open;
  If EAQuery.FindFirst then ShowMessage('1st Record Found')
    else ShowMessage('There was a problem finding the 1st record');

EAQuery has been defined previously and the connection is working fine - I know that because I can retrieve values from the first row and can therefore retrieve the value from a "Select Count(*)" statement and check the value.

I need to use findFirst and findNext to enumerate the rows.

Any thoughts or suggestions?

John.
0
Comment
Question by:Jaymol
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 50 total points
ID: 6405874
hmmm

  I'm not sure if I understood you well, but if you want to move between the records, use First, Next, Last and Prior

0
 
LVL 6

Author Comment

by:Jaymol
ID: 6406065
Thanks, but I'm saying that FindFirst is not working.

John.
0
 
LVL 4

Expert Comment

by:fva
ID: 6406131
FindFirst is an internal method used for navigating within a filtered data set. You did not set any filter (at least not in the example you posted).

But really, wouldn't you get into a performance problem if you do filtering over a remote-obtained result-set? Usually far better performance is obtained by restricting the result set in the select statement itself. Thus, the hard work is done at the server level (I presume you have a true SQL backend since you mentioned some connection) and even the network traffic may be significantly reduced.

But yet again your particular setup might require it so I'm just placing a suggestion.

F.
0
 
LVL 6

Author Comment

by:Jaymol
ID: 6406149
Sorry, I misunderstood your comment.  Using First and Next, not FindFirst and FindNext, is exactly what I wanted.

Fva, this application will be used maybe twenty to thirty times a year so I'm not concerned about performance issues, but thanks for the tips.  Worth bearing in mind in the future.

Thanks guys,

John.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question