Seeing database changes in a DBGrid


I'm using the ADO components to access an Access database.

I've a TDBGrid pointing to a TDataSource pointing to a TADOTable, giving me a list of what's in that table.

I make a change using a query somewhere else.

How do I get the table to reflect the changes? (In this case an added record, but I'll probably want to delete and modify stuff shortly..)



(Actually using C++Builder, but the database Gurus tend to hang out in this TA!)
LVL 12
andrewjbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

esoftbgCommented:
TADOTable.Requery
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tomas Helgi JohannssonCommented:

use    
 ADOTable.Refresh;

after executing the insert/update/delete query

Regards,
  Tomas Helgi
0
andrewjbAuthor Commented:
I'd tried refresh - it doesn't work for some reason.

Requery is great. Anyone know why?
0
Amir AzhdariCommented:
from delphi help :

REQUERY :
Call Requery to refresh the recordset. Requery updates the dataset by re-executing the original command or SQL statement that produced the recordset.

The effects of Requery are the same as calling the dataset’s Close method and then its Open method. However, there are circumstances when one means of refreshing the recordset is better than the other. The values in properties like CursorLocation, CursorType, and LockType cannot be changed while the dataset is open, so Requery can only refresh the recordset using the existing values in these properties. To refresh the recordset using different values for these properties, effect the refresh using the Close and Open methods.

Options is a TExecuteOptions value that specifies the characteristics of the command execution affected by the requery that produces the recordset for the dataset.


REFRESH :
The Refresh method does not work for all TDataSet descendants. In particular, TQuery components do not support the Refresh method if the query is not “live”. To refresh a static TQuery, close and reopen the dataset.



by the way , don't accept this comment as answer please
Regards
Amir
0
andrewjbAuthor Commented:
Yup - read that. It's a table, though, not a query. Perhaps just one of Delphi's quirks..

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.