最近写一个财务管理的作业,发现用AdoQuery写了一条插入语句后居然在DBGrid中不能更新显示最新的那一条记录,而要点击两次更新按钮才行,更新按钮的代码如下
FormShowGeneral.ADOTable1.Open;
FormShowGeneral.ADOTable1.Close;
FormShowGeneral.ADOTable1.Open;
FormShowGeneral.ADOTable1.UpdateBatch();
FormShowGeneral.ADOQueryShowGeneral.Close;
FormShowGeneral.ADOQueryShowGeneral.SQL.Clear;
FormShowGeneral.ADOQueryShowGeneral.SQL.Add('Select * from GeneralTable');
FormShowGeneral.ADOQueryShowGeneral.Open;
FormShowGeneral.DBGrid1.Refresh;
FormShowGeneral.ShowModal;
这样怎么都能更新吧,虽然有冗余代码,但实际情况是要点击两次,郁闷啊