Solved

TSQLQuery.FindFirst

Posted on 2001-08-20
4
275 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now