Data.DB.TDataSet.Refresh

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure Refresh;

C++

void __fastcall Refresh();

Properties

Type Visibility Source Unit Parent
procedure
function
public
Data.DB.pas
Data.DB.hpp
Data.DB TDataSet

Description

Re-fetches data from the database to update a dataset's view of data.

Call Refresh to ensure that an application has the latest data from a database. For example, when an application turns off filtering for a dataset, it should immediately call Refresh to display all records in the dataset, not just those that used to meet the filter condition.

Note: 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.

TDataSet generates a BeforeRefresh event before refreshing the records and an AfterRefresh event afterwards.

Note: Most datasets try to maintain the current record position when you call refresh. However, this is not always possible. For example, the current record may have been deleted from the server by another user. Unidirectional datasets have no mechanism for locating the current record after a refresh, and always move back to the first record.

Warning: Unidirectional datasets refresh the data by closing and reopening the cursor. This can have unintended side effects if, for example, you have code in the BeforeClose, AfterClose, BeforeOpen, or AfterOpen event handlers.

See Also


Code Examples