7

I have a TDBGrid called myDbGrid that I want to update after a change to the database (insert/update/delete). How can I do this without reloading my form completely?

myDbGrid uses myDataSource and it uses myQry as its data set.

I've tried the following with no success:

myDbGrid.Refresh;

and

myDbGrid.DataSource.DataSet.Close;
myQry.Close; // '' I think this is redundant
myQry.Open;
myDbGrid.DataSource.DataSet.Refresh;

What have I missed?

(I'll note that the database change is not happening in the tDBGrid - it's there for display only)

4

3 回答 3

10

这里需要的唯一代码是:

myDbGrid.DataSource.DataSet.Refresh; 

在这种特殊情况下,其他一切都是多余的。

于 2015-03-02T14:51:33.337 回答
0

我正在使用 ADOQuery,所以我做了:

ADOQuery1.Active := False;
ADOQuery1.Active := True;
于 2021-08-11T17:56:27.640 回答
0

你可以试试这段代码:

ADOQuery.SQL.Clear;
ADOQuery.SQL.Add('select* from table_name');
ADOQuery.Open;
于 2018-09-21T08:50:54.730 回答