?
Solved

Get number of record after FILTER usig TwwFilterDialog

Posted on 2004-09-10
10
Medium Priority
?
1,210 Views
Last Modified: 2007-11-27
I want to get a number of record (ADODataSet) after user filter the recordset using TwwFilterDialog or could any of you can recommend me a suitable Filter Component.

after open dataset may be record count = 300
after filter dataset may be filtered record count = 100, how can I get this value.
0
Comment
Question by:soapsiam
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12024285
0
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 12024480
This is already implemented in TwwFilterDialog...

The result is correctly returned if you use a TwwTable or twwquery query but as you're using AdoDatasets you have to change the FilterPropertyOption in TwwFilterDialog to fdUseFilterProp. (This is the reccomended by InfoPower using Ado).

Then this will show the real filtered recordcount.

procedure TForm1.Button1Click(Sender: TObject);
begin
wwfilterdialog1.FilterPropertyOptions.DatasetFilterType :=fdUseFilterProp;
wwfilterdialog1.Execute;
label1.Caption := inttostr(adotable1.RecordCount);
end;

0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12026427
TwwFilterDialog? Never used it anyway.

Unless I'm mistaken, an ADODataset has "Filter" and "Filtered" properties. If Filtered is true, the filter will be applied and if I'm not mistaken, this will update the recordcount.

If not, set a bookmark on the current record, disable the controls, go to the first record and then walk through the whole recordset counting every record until EOF. Go back to the bookmarked record, enable the controls and you're done. But I think RecordCount would work if you use the Filter property.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 12026482
-->  But I think RecordCount would work if you use the Filter property.
Sorry not, all tdataset descendents returns the first opened recordset recordcount always, even if you apply a filter.

BTW TwwFilterDialog is a InfoPower component. A customizable filter dialog for filtering on datasets fields. And as already said, this feauture is already supported by it just without code additions....

F68 ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12027024
>this feauture is already supported by it just without code additions....

well, then my link above is not needed . . .

meikl ;-)
0
 

Expert Comment

by:iman_a_r
ID: 12027465
Hi,
I had the same problem with Filte and prefer to use SQL inseted of Filter.

You can use Queries component insted of Tables.
Using Query and Table is the same.

Let have an example.

-------------------- With table
Table.Name:='table1';
...
Table.Filter='Age=10';
Table.Filtered=True;

------------------------------ With Query
Query.SQL.add('Select * from Table1 where Age=10');


if it can be a good solution i can give you a sample.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12028411
@iman_a_r,
The use of a filter should, in general, improve the performance. If the recordset is very large, and still large after a filter is applied, using a filter on the query performs faster than re-querying the recordset with an additional filter. Especially if the database is located on another system and you have to use the network to send over the records. The ADODataset.Filter will execute the filter on the client, thus not causing any more network traffic to the server. Your suggestion would demand another large amounts of records to be sent back to the client.
Thus, in my personal view, inefficient for client-server solutions. But okay for local databases.

@f68,
> Sorry not, all tdataset descendents returns the first opened recordset recordcount always, even if you apply a filter.
It does? And the ADODataset.Recordset.RecordCount property then? The ADODataset is just a TRecordset wrapper around the ADO components. If I'm not mistaken, the TADODataset will return the value from the _Recordset underneath. The filter itself will also be passed to the _Recordset, and I would expect MicroSoft to be smart and return the right amount of records after the filter has been set.
Unfortunately, I can't test it right now...
0
 
LVL 6

Expert Comment

by:bpana
ID: 12028692
@f68,
> Sorry not, all tdataset descendents returns the first opened recordset recordcount always, even if you apply a filter.

That's not true. Workshop_Alex is right.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12036132
@bpana, of course I'm right :D
0
 
LVL 1

Author Comment

by:soapsiam
ID: 12061948
I use TwwFilterDialog as it is allow end user to buid their own filter condition so I don't have to write it.

As I use Client side cursor of ADO, if using .Filter := 'Some thing here';
and Filtered := True; It update RecordCount property. But that is not the case with TwwFilterDialog.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

862 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