Seeing database changes in a DBGrid

Posted on 2004-11-04
Last Modified: 2010-04-05

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!)
Question by:andrewjb
    LVL 12

    Accepted Solution

    LVL 24

    Expert Comment

    by:Tomas Helgi Johannsson


    after executing the insert/update/delete query

      Tomas Helgi
    LVL 12

    Author Comment

    I'd tried refresh - it doesn't work for some reason.

    Requery is great. Anyone know why?
    LVL 6

    Expert Comment

    by:Amir Azhdari
    from delphi help :

    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.

    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
    LVL 12

    Author Comment

    Yup - read that. It's a table, though, not a query. Perhaps just one of Delphi's quirks..


    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    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…
    In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now