query1.applyupdates[query1];这一句错在哪

解决方案 »

  1.   

    HELP中写道:
    Call ApplyUpdates to write a dataset pending cached updates to a database. This method passes cached data to the database for storage, but the changes are not committed to the database. An application must explicitly call the database component抯 Commit method to commit the changes to the database if the write is successful, or call the database Rollback method to undo the changes if there is an error.e.g.
    he following procedure illustrates how to apply a dataset cached updates to a database in response to a button click:procedure TForm1.ApplyButtonClick(Sender: TObject);begin
      with CustomerQuery do
      begin
      Database1.StartTransaction;
        try
          ApplyUpdates; {try to write the updates to the database};
          Database1.Commit; {on success, commit the changes};
        except
          Database1.Rollback; {on failure, undo the changes};
        raise; {raise the exception to prevent a call to CommitUpdates!}
        end;
      CommitUpdates; {on success, clear the cache}
      end;end;
      

  2.   

    呵呵,还是不懂。Database1是指什么?
      

  3.   

    自己弄了会,出来一个no sql statement available的出错信息来,是在我更改了查询出的记录后出现的,什么意思?
      

  4.   

    难道是要在什么地方写上sql语句?在updatesql上写?我的那段语句是在query1的afterpost中加上:table1.close;
    datasource1.dataset:=query1;
    query1.applyUpdates;
    结果是会出提示,确定后能改变记录,但不能保存。