Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Show progress while opening a clientdataset.

1,025 views
Skip to first unread message

Anil Jagtap

unread,
Apr 1, 2003, 2:45:30 AM4/1/03
to
Hi all

How can I Show progress bar when i am opening my clientdataset;

Say i am opening customers table and it contain ten hundred thousands of
records and i want to open them all at a time for loading into memory
dataset so what happens is ; which i say open to that clientdataset so first
it opens and nothing happens sometimes i think as if my machine is hang but
after sometime this process of loading into memory dataset starts. So is
there some way that i can show a progress bar when it is opening tat query
into that clientdataset.


Also I am looking for a procedure which I can use it in common for executing
SQLQueries;

Now presently I do the following way for all queries ;

cdsUpdate := TClientDataSet.Create(nil);
try
cdsUpdate.RemoteServer := RemoteConnection;
cdsUpdate.ProviderName := 'dspUpdate';
with cdsUpdate do begin
Close;
Params.Clear;
Params.CreateParam(ftString, 'pHeatName', ptInput);
Params.CreateParam(ftString, 'pRace_ID', ptInput);
CommandText := 'Update Race Set Heat_Name =:pHeatName Where
Race_ID=:pRace_ID';
Params.ParamByName('pHeatName').AsString := 'abc';
Params.ParamByName('pRace_ID').AsInteger := 123;
try
cdsUpdate.Execute;
except
on E: Exception do FireException(E.Message);
end;
Params.Clear;
Close;
end;
finally
cdsUpdate.Free;
end;


So does anyone have some kind of following :

RunQuery([ftString, ftString], ['pHeatName', 'pRace_ID'], ['abc', 123]);

So in above query I will pass all parameters of ftTypes, and the params to
create and their respective values and this query will run in a separate
thread.

Thanks,

Regards,

Anil Jagtap.


Bill Todd

unread,
Apr 1, 2003, 9:04:11 AM4/1/03
to
A better solution is to rethink your application design. You should
never load 100,000+ records across the network into a CDS. There has
to be a better way to accomplish what you need.


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Anil Jagtap

unread,
Apr 2, 2003, 5:42:33 AM4/2/03
to
Hi Bill

Well this loading of all records i will be doing only once on the start of
application later everything i keep in Memory Dataset, so eben though if it
takes 5 minutes for loading no problem but later overall in my application i
have a good speed with my customers and i just add one records to this
memory dataset when a new customer is added alongwith my database.

But as you said there has to be a better way to accomplish this, so can you
also suggest me like how can i do this.

Thanks,

Regards,

Anil Jagtap

"Bill Todd" <bi...@notthis.dbginc.com> wrote in message
news:mv6j8vg6cb8ii8ja3...@4ax.com...

Bill Todd

unread,
Apr 2, 2003, 9:24:18 AM4/2/03
to
>But as you said there has to be a better way to accomplish this, so can you
>also suggest me like how can i do this.

Normal client/server design is to show the user a blank form when the
application starts and require the user to enter selection criteria to
fetch a small number of records to work with. After the user is done
with that batch of records and you have called ApplyUpdates(0) the
user enters new selection criteria and gets the next batch of records
from the database server.

Anil Jagtap

unread,
Apr 3, 2003, 12:16:45 AM4/3/03
to
Yeah thats True but my clients requirement is that he wants to see all the
customers at a glance and he wants to play with all those records like
Searching, Filtering, Navigating, etc..... So what i do is I have Memory
DataSets which is ultimate fast almost 100 times faster that normal
clientdataset, so i load from database and dump everything into this memory
dataset and my client plays with that so he is happy, but now he is sad and
says if while loading can u show the progress bar of load bcos sometimes it
takes too long so we dont know whether the application is really doing
something / nothing.

So what can i do to this...

Thankyou very much... Waiting for your reply asap..

Regards,

Anil Jagtap.


"Bill Todd" <bi...@notthis.dbginc.com> wrote in message

news:hgsl8vo00flq3av9k...@4ax.com...

Wayne Niddery [TeamB]

unread,
Apr 3, 2003, 9:51:59 AM4/3/03
to
"Anil Jagtap" <aja...@hitech-outsourcing.com> wrote in message
news:3e8c...@newsgroups.borland.com...

> Yeah thats True but my clients requirement is that he wants to see all the
> customers at a glance and he wants to play with all those records like
> Searching, Filtering, Navigating, etc..... So what i do is I have Memory
> DataSets which is ultimate fast almost 100 times faster that normal
> clientdataset, so i load from database and dump everything into this
memory
> dataset and my client plays with that so he is happy, but now he is sad
and
> says if while loading can u show the progress bar of load bcos sometimes
it
> takes too long so we dont know whether the application is really doing
> something / nothing.
>
> So what can i do to this...

Drop an Animation control on the form and activate it until the load is
done.


--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
"Democracy, without that guarantee of liberty, is merely a method of
selecting tyrants." - Alan Nitikman


Bill Todd

unread,
Apr 3, 2003, 9:50:18 AM4/3/03
to
There is no way to get progress information that I am aware of.

Bill Todd

unread,
Apr 3, 2003, 12:47:13 PM4/3/03
to
>Drop an Animation control on the form and activate it until the load is
>done.

But that's entertainment, not progress.<g>

Dan Palley

unread,
Apr 4, 2003, 1:00:32 PM4/4/03
to
Getting progress feedback while fetching the results should be easy. Set
the clientdataset packetrecords >0 and write a loop that fetches the packets
until packetsize=0 meaning the whole dataset has been retrieved. Inside the
loop, you can display your progress bar and give the user an opportunity to
cancel the retrieval:

BookingCDS.PacketRecords:=100;
BookingCDS.Open;
While (BookingCDS.GetNextPacket<>0) And Not CancelQuery Do
Begin
ProgressLabel.Caption:=IntToStr(BookingCDS.RecordCount);
Application.ProcessMessages;
End;

Dan

"Anil Jagtap" <aja...@hitech-outsourcing.com> wrote in message
news:3e8c...@newsgroups.borland.com...

Anil Jagtap

unread,
Apr 10, 2003, 2:50:35 AM4/10/03
to
Hi Dan,

I do the following;

procedure LoadMembers(const ShowProgressWhere: String = '');
var cdsCust: TClientDataSet;
begin
Screen.Cursor := crHourGlass;
with dmSMS.cdsMemCust do begin // dmSMS.cdsMemCust is a memory
dataset - TkbmMemTable //
Close;
MasterSource := nil;
with dmSMS.cdsMemCust.FieldDefs do begin
Clear;
Add('ID', ftInteger, 0, False);
end;
end;
cdsCust := TClientDataSet.Create(nil);
cdsCust.RemoteServer := frmMainForm.DCOMConnection1;
cdsCust.ProviderName := 'dspBlank';
try
cdsCust.CommandText := ' Select Cust_ID, Prod_ID, Cust_Title,
'+
' F_ProperCase(Cust_NickName) Cust_NickName,
'+
' F_ProperCase(Cust_FirstName) Cust_FirstName,
'+
' F_ProperCase(Cust_LastName) Cust_LastName,
'+
' Cust_Phone, Cust_Fax, Cust_Mobile, Cust_Email,
'+
' Cust_Class, Card_Number, Card_Expiry,
Rec_Status, '+
' Cust_PhotoPath From Customer Where Cust_Class
<> 0 '+
' and Rec_Status = ''N''
';
cdsCust.Open;
try
dmSMS.cdsMemCust.LoadFromDataSet(cdsCust, [mtcpoStructure]);
finally
cdsCust.Close;
cdsCust.Params.Clear;
end;
finally
Screen.Cursor := crArrow;
cdsCust.Free;
end;
end;

So in this case when i say cdsCust.Open then he waits there till it is
opened in cdsCust's memory, and then after this it works in few span of
msecs, so where i have to write what you specified ;

Thanks again,

Regards,

Anil Jagtap.

------------------------------


"Dan Palley" <d...@trams.com> wrote in message
news:3e8dc929$1...@newsgroups.borland.com...

Linda Murphy

unread,
Apr 14, 2003, 3:38:41 PM4/14/03
to
To quote the Delphi help file:

Use TProgressBar to add a progress bar to a form.
Progress bars provide users with visual feedback about
the progress of a procedure within an application. As
the procedure progresses, the rectangular progress bar
gradually fills from left to right with the system
highlight color.
=====

Ideally, one knows approximately the total number of rows one is about
to fetch, and for each iteration of the loop that's doing the fetching
one can increase the ProgressBar's position, or use its "StepIt" method.

TProgressBar is a better visual representation of progress than
animation, a spinning cursor, or even progresslabel.caption :=
IntToStr(recordcount). Perhaps it's even more entertaining :-)

Linda


Anil Jagtap

unread,
Apr 15, 2003, 12:58:44 AM4/15/03
to
Hi Linda,

Well I dont think this shall be that because I wanna show my progress bar
while i am opening my clientdataset and the no of records i will get when it
is opened, so after that its of no use... bcos as u said to get the nr of
records and using step it, so that is later stage when i am transferring
those records in my memory dataset.

Anyway, Thanks,

Anil.


"Linda Murphy" <koto...@juno.com> wrote in message
news:3e9b...@newsgroups.borland.com...

William Buchanan

unread,
Apr 25, 2003, 7:42:51 AM4/25/03
to
Run an sql before you open your Clientdataset which will give you the number
of records. E.g.

select count(*) as TOTAL_RECORDS from TABLE1 T1 where T1.FIELD1 = 'XYZ';

You can then set the progressbar max value....

HTH

Will

"Anil Jagtap" <aja...@hitech-outsourcing.com> wrote in message

Derek

unread,
Apr 28, 2003, 5:31:59 PM4/28/03
to
Why worry about an exact progress bar. You know it roughly takes 5 minutes
so just increment it until 5 minutes is up.......when the query ends make
the progress bar full.

The user wont have a clue what the difference is

"Anil Jagtap" <aja...@hitech-outsourcing.com> wrote in message

news:3e89...@newsgroups.borland.com...

Dave Rowntree

unread,
Apr 29, 2003, 5:29:03 AM4/29/03
to
Be aware that setting CDS.PacketRecords > 0 means multiple round trips to
the appserver just to open the CDS. Setting CDS.PacketRecords = 100 with
200,000 records would mean 2,000 round trips to the appserver just to open
the CDS. This would not be concidered good n-tier practice. Nor would
bringing 200,000 records accross a network into a CDS.

Educate the user. Revisit the analysis of what he is doing, why he is doing
it, what needs to be achieved, there has to be a better alternative.

--
-Dave Rowntree

epibl...@gmail.com

unread,
Apr 4, 2013, 10:27:53 AM4/4/13
to Anil Jagtap
Hi there,

There is away to do this which has worked well for me ...

create your main ClientDataSet that you will use ...


create a thread that creates its own connection ... query .. dataprovider ... and clientdataset ....

connect the cds.providername to the dataprovider in the thread then assign the

query.connection := connection;
provider.dataset := query;
clientdataset.open;

because this is running in a thread there will be no hanging of the main thread while you retrieve the data...

create an onterminate procedure and assign it to Thread.Onterminate.


in this procedure do this

MainCDS.AppendData( thread.acds.Data, true );

and SHAZAM ....

the data in the thread is now in your main thread and you are ready to fetch the next lot ...

** just use LIMIT 1000 in your query to fetch only that much at a time or less you can drop a progressbar on the form set its max to 200k then on every thread terminate add 1000 to its position and there you go :)

0 new messages