如果检查adotable中是否有需要保存的数据?即adotable中是否添加或者修改了数据并且尚未保存?

解决方案 »

  1.   

    type TDataSetState = (dsInactive, dsBrowse, dsEdit, dsInsert, dsSetKey, dsCalcFields, dsFilter, dsNewValue, dsOldValue, dsCurValue, dsBlockRead, dsInternalCalc, dsOpening); 
    if form1.ADOTable1.State=dsEdit then showmessage('edit');
      

  2.   

    判断adotable.state
        if (ADOTable1.State=dsEdit) or ((ADOTable1.State=dsInsert)) then
            ShowMessage('Edit or Insert');dsInactive Dataset is closed, so its data is unavailable.
    dsBrowse Data can be viewed, but not changed. This is the default state of an open dataset.
    dsEdit Active record can be modified.
    dsInsert The active record is a newly inserted buffer that has not been posted. This record can be modified and then either posted or discarded.
    dsSetKey TTable and TClientDataSet only. Record searching is enabled, or a SetRange operation is under way. A restricted set of data can be viewed, and no data can be edited or inserted.dsCalcFields An OnCalcFields event is in progress. Noncalculated fields cannot be edited, and new records cannot be inserted.
    dsFilter An OnFilterRecord event is in progress. A restricted set of data can be viewed. No data can edited or inserted.
    dsNewValue Temporary state used internally when a field component’s NewValue property is accessed.
    dsOldValue Temporary state used internally when a field component’s OldValue property is accessed.
    dsCurValue Temporary state used internally when a field component’s CurValue property is accessed.dsBlockRead Data-aware controls are not updated and events are not triggered when moving to the next record.
    dsInternalCalc Temporary state used internally when values need to be calculated for a field that has a FieldKind of fkInternalCalc.
    dsOpening DataSet is in the process of opening but has not finished. This state occurs when the dataset is opened for asynchronous fetching.
      

  3.   

    如果是批提交的话,你可以
    方法一:设置一个单元全局变量changed.
    在各个字段的onchange是将changed:=true;
    然后只要判断changed就可以了.方法二:在dataset.onpost中changed := true;
    batchdate时判断.
      

  4.   

    if AdoTable.State in [dsEdit,dsInsert] then ......此时处在修改或插入状态