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

How to refresh TQuery

121 views
Skip to first unread message

Amin

unread,
Jun 12, 2001, 9:39:10 PM6/12/01
to
Hi. All

I Have a problem in my project..
I develop database application and use TQuery to view and update data,
but TQuery have no metode for refresh dataset, so I have been close and open
TQuery to refresh dataset. that way not efective because potition a pointer
cursor always on top and I have to locate last potition of record.
I see in TIBQuery have metode for refresh dataset.
Any sugestion for its.... ?

Amin.


Christopher Latta

unread,
Jun 12, 2001, 10:52:07 PM6/12/01
to
Amin <ami...@hotmail.com> wrote in message news:3b26c304_1@dnews...

> I Have a problem in my project..
> I develop database application and use TQuery to view and update data,
> but TQuery have no metode for refresh dataset, so I have been close and
open
> TQuery to refresh dataset. that way not efective because potition a
pointer
> cursor always on top and I have to locate last potition of record.
> I see in TIBQuery have metode for refresh dataset.

Closing and opening is the only way to do it for a TQuery. Perhaps you could
order your data last-to-first so that the record you want is always on top?

Christopher Latta

Amin

unread,
Jun 13, 2001, 1:18:00 AM6/13/01
to
To. Christopher Latta
Thanks for your explan.

are you have a procedure for refresh TQuery ?

regards,
Amin.

"Christopher Latta" <nob...@nowhere.not> wrote in message
news:3b26d6cb_2@dnews...

Craig Stuntz (TeamB)

unread,
Jun 13, 2001, 9:49:58 AM6/13/01
to

Amin wrote:
>
> I develop database application and use TQuery to view and update data,
> but TQuery have no metode for refresh dataset, so I have been close and open
> TQuery to refresh dataset. that way not efective because potition a pointer
> cursor always on top and I have to locate last potition of record.

That's the correct way to do it. It's also the same thing as
TTable.Refresh does internally.

> I see in TIBQuery have metode for refresh dataset.

TIBQuery.Refresh refreshes the current record only. To refresh the
entire selection with IBQuery, you need to do exactly what you've
described above.

HTH,

-Craig

--
Craig Stuntz (TeamB) Senior Developer, Vertex Systems Corp.
Delphi/InterBase weblog: http://delphi.weblogs.com
Use Borland servers; posts via others are not seen by TeamB.
For more info, see http://www.borland.com/newsgroups/genl_faqs.html

David Gagnon

unread,
Jun 13, 2001, 11:28:37 AM6/13/01
to
We reclassed the objects added new features. One of them was refresh.

This is the code in the public section of the reclassed object
procedure Refresh(aKeepPos : boolean = True; aPrimaryKeyFieldName : string
= 'PK');

procedure TMLSQuery.Refresh;
var
iStorePK : Integer;
begin
try
DisableControls;
iStorePK := 0;
if aKeepPos then
iStorePK := FieldByName(aPrimaryKeyFieldName).AsInteger;
Close;
Open;
if aKeepPos and (iStorePK <> 0) then
try Locate(aPrimaryKeyFieldName, iStorePK, []) except end;
finally
EnableControls;
end;
end;

Heres a couple sample calls
MyQuery.Refresh;
MyQuery.Refresh(False);
MyQuery.Refresh(True,'DifferentPrimaryKeyField');

"Amin" <ami...@hotmail.com> wrote in message news:3b26f650_2@dnews...

Amin

unread,
Jun 13, 2001, 9:44:38 PM6/13/01
to
To. David Gagnon
Thanks alot form your ideas, but I still confusing about
aPrimaryKeyFieldName.
in your procedure I must include one of many field name as
aPrimaryKeyFieldName.
Can I detect PrimaryKeyFieldName without include afieldname as primary key ?
because my tables have primary key not only integer/string field..

Sorry, my english not good.

regards,
Amin.
"David Gagnon" <le...@freeway.net> wrote in message
news:3b27861a$1_1@dnews...

Amin

unread,
Jun 13, 2001, 10:09:54 PM6/13/01
to
To. Craig Stuntz (TeamB)
Thanks for your explan.
I understand it more now.
in another case, I found a function "Fetchall".
what differences between "fetchall" and "applyupdates" ?

regards,
Amin

Amin

unread,
Jun 13, 2001, 10:09:35 PM6/13/01
to
what differences between "fetchall" and "applyupdates".

regards,
Amin

Craig Stuntz (TeamB)

unread,
Jun 14, 2001, 10:05:36 AM6/14/01
to

Amin wrote:
>
> in another case, I found a function "Fetchall".
> what differences between "fetchall" and "applyupdates".

They have nothing to do with one another.

FetchAll retrieves every record from the DB server and buffers it on
the client.

ApplyUpdates is used only with Cached Updates (or TClientDataset) and
is used to tell the TQuery to post all cached changes to the DB server.
Because it depends on Paradox, among other reasons, I strongly recommend
that you do not use Cached Updates with TQuery when your DB back end is
a C/S database.

Rogelio Argueta

unread,
Jun 14, 2001, 12:13:24 PM6/14/01
to
Hi Craig!

"Craig Stuntz (TeamB)" wrote:

>
> ApplyUpdates is used only with Cached Updates (or TClientDataset) and
> is used to tell the TQuery to post all cached changes to the DB server.
> Because it depends on Paradox, among other reasons, I strongly recommend
> that you do not use Cached Updates with TQuery when your DB back end is
> a C/S database.

What is your recommendation or the best way to work with TQuerys?

This question is because we are working with D5 and Oracle 8i and we use Tquerys
and cache updates. Are we "walking" in the wrong direction?

Craig Stuntz (TeamB)

unread,
Jun 14, 2001, 12:45:12 PM6/14/01
to

Rogelio Argueta wrote:
>
> What is your recommendation or the best way to work with TQuerys?

Either don't cache updates at all or do it with TClientDataset.



> This question is because we are working with D5 and Oracle 8i and we use Tquerys
> and cache updates. Are we "walking" in the wrong direction?

The BDE's implementation of cached updates uses Paradox errors
internally. When used in a multiuser configuration, Paradox tends to
become unstable. There are fixes for most of the issues, but some of
them are rather involved, and involve updating the OS at each customer
installation. IMHO, it's more trouble than it's worth. TQuery works
fine if you don't cache updates, and if you do want to cache updates
then using TClientDataset instead will give you a growth path to
DataSnap and n-tier architectures.

Personally, I don't like caching updates, as I feel that the server
should always be the final arbiter of what is or is not allowed into the
DB.

Kevin Frevert

unread,
Jun 14, 2001, 12:57:17 PM6/14/01
to

Craig Stuntz (TeamB) <cstuntz@no_spam.vertexsoftware.com> wrote in message
news:3B28EA18.932464FD@no_spam.vertexsoftware.com...

> Personally, I don't like caching updates, as I feel that the server
> should always be the final arbiter of what is or is not allowed into the
> DB.

Just curious, how is cachedupdates (versus MIDAS/DataSnap) not allowing the
sever to be the final arbiter?

krf


Rogelio Argueta

unread,
Jun 14, 2001, 1:28:54 PM6/14/01
to
Thank you Craig for the explanation but:

"Craig Stuntz (TeamB)" wrote:

> Rogelio Argueta wrote:
> >
> > What is your recommendation or the best way to work with TQuerys?
>
> Either don't cache updates at all or do it with TClientDataset.

I can't find the TClientDataset in my Data Access palette. Where is it?


>
>
> > This question is because we are working with D5 and Oracle 8i and we use Tquerys
> > and cache updates. Are we "walking" in the wrong direction?
>
> The BDE's implementation of cached updates uses Paradox errors
> internally. When used in a multiuser configuration, Paradox tends to
> become unstable. There are fixes for most of the issues, but some of
> them are rather involved, and involve updating the OS at each customer
> installation. IMHO, it's more trouble than it's worth. TQuery works
> fine if you don't cache updates, and if you do want to cache updates
> then using TClientDataset instead will give you a growth path to
> DataSnap and n-tier architectures.

Is there a friendly help to learn the use of this component?


Craig Stuntz (TeamB)

unread,
Jun 14, 2001, 5:32:01 PM6/14/01
to

Kevin Frevert wrote:
>
> Just curious, how is cachedupdates (versus MIDAS/DataSnap) not allowing the
> sever to be the final arbiter?

It's just a user interface issue. IMHO, it's a bad idea to let the
user leave a record when it contains invalid data -- having to wade
through a long list of reconcile errors later on is burdensome on the
non-technical user. This means you need to either re-implement server
constraints on the client (error-prone) or not cache updates.

That said, I do like the "DataSnap as a replacement for cached updates"
architecture, because it allows very easy upscaling to n-tier
architectures. I just ApplyUpdates after every post.

Again, IMHO,

Craig Stuntz (TeamB)

unread,
Jun 14, 2001, 5:34:50 PM6/14/01
to

Rogelio Argueta wrote:
>
> I can't find the TClientDataset in my Data Access palette. Where is it?

On D5E it's in the MIDAS tab. On D6P/E it's on the Data Access tab.

> Is there a friendly help to learn the use of this component?

Yes:

http://www.borland.com/midas/papers/clientdataset

Rogelio Argueta

unread,
Jun 14, 2001, 5:45:05 PM6/14/01
to
Thank's again Craig!


0 new messages