Board index » delphi » Query.Refresh doesn't work?

Query.Refresh doesn't work?

Hi

I'm using a TTable and TQuery working both in the same table; I use the
query to display the data with order, filters, joins, etc, and the table to
edit/insert data.  When I edit or insert something, the dbGrid who displays
my query doesn't change, so I tried using the query.refresh method, and this
didn't work.  If I close and open the query it works, but it is slow and I
lose the position, so I would have to use bookmarks.
What is the problem with the refresh?

Thanx

 

Re:Query.Refresh doesn't work?


TQueries require that the result set be determined by the DB engine.  You must
close/open to refresh the data.  You can try saving the primary key before
closing and locating that key on the reopen.

Quote
Alejandro Marcu wrote:

> Hi

> I'm using a TTable and TQuery working both in the same table; I use the
> query to display the data with order, filters, joins, etc, and the table to
> edit/insert data.  When I edit or insert something, the dbGrid who displays
> my query doesn't change, so I tried using the query.refresh method, and this
> didn't work.  If I close and open the query it works, but it is slow and I
> lose the position, so I would have to use bookmarks.
> What is the problem with the refresh?

> Thanx

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
Mild mannered supermen are held in kryptonite, and the wise and foolish
{*word*269}s giggle with their bodies glowing bright.  Through the door a harvest
feast is lit by candlelight; it's the bottom of the staircase that spirals out
of sight.
  (new classic Genesis) Carpet Crawlers 1999
--

Re:Query.Refresh doesn't work?


Quote
> If I close and open the query it works, but it is slow and I
>lose the position, so I would have to use bookmarks.

Bookmarks won't work, either. Bookmarks are not persistent across a
close/open sequence. What I do is simpe brute force -- I wrote a generic
little routine to save the values of the first 10 fields of the dataset into
a variant array before closing the query (this ensures that I've gotten all
the primary key fields in a generic way). Then re-open the query and use the
saved values to locate my record. Ugly, but it works.

Other Threads