?
Solved

Get number of record after FILTER usig TwwFilterDialog

Posted on 2004-09-10
10
Medium Priority
?
1,174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
10 Comments
 
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
Independent Software Vendors: 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

770 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