数据源的CachedUpdates已经设为True了,

解决方案 »

  1.   

    你在Query的AfterScroll里执行Edit()方法,应该能保持Query数据集的修改状态。
      

  2.   


     嗨,用Query的Edit能修改记录?说说详细情况,大家讨论一下。
      

  3.   

    hecf, 你不知道Query的数据集是可以修改的吗?:)
      

  4.   


    是的,我不知道Query的数据集可以修改。请问如何进行修改?
      

  5.   

     
      在NT40 + SP6 + SQL SERVER7下,我照你的做法可以行得通。详细如下:    控件有:    
        DataSource1: TDataSource;
        Query1: TQuery;
        Database1: TDatabase;
        DBGrid1: TDBGrid;
        DBNavigator1: TDBNavigator;
        BitBtn1: TBitBtn;    属性如下:
        Query1.RequestLive := true;
        Query1.CachedUpdates := true;
        其他为默认值。
        
        在BitBtn1中的数据提交一切正常:
      with Query1 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;  估计是你的版本有问题,或其他原因。
      谢谢你,是你让我知道了RequestLive属性的用法。下次见。
      

  6.   


      在NT40 + SP6 + SQL SERVER7下,我照你的做法可以行得通。详细如下:    控件有:    
        DataSource1: TDataSource;
        Query1: TQuery;
        Database1: TDatabase;
        DBGrid1: TDBGrid;
        DBNavigator1: TDBNavigator;
        BitBtn1: TBitBtn;    属性如下:
        Query1.RequestLive := true;
        Query1.CachedUpdates := true;
        其他为默认值。
        
        在BitBtn1中的数据提交一切正常:
      with Query1 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;  估计是你的版本有问题,或其他原因。
      谢谢你,是你让我知道了RequestLive属性的用法。下次见。
      

  7.   

        我的问题已经解决,虽然不是按照大家的指点去做的,但还是要谢谢大家。
        我的做法如下(开发环境Win98SE+Delphi3+SQL Server6.5):
    控件:DataSource1: TDataSource;
         Query1: TQuery;
         DBGrid: TDBGrid;
    属性设置:Query1的CachedUpdated设为True,RequestLive设为True;
             DataSource1的AutoEdit设为True;
             DBGrid的Options的dgEditing设为False;//不允许DBGrid进行编辑操作
             其余为默认值;
    这样子使得使得Query1始终处于编辑状态,但是DBGrid不能编辑,看起来还是和Query的浏览状态相同。
        在要进行增加或者修改操作时,再把DBGrid的Options的dgEditing设为True;即允许DBGrid进行编辑,这样子就可以一次编辑操作同时修改多条记录,而且在焦点跳转到别的记录时不会自动Post。    再次谢谢大家!!!
      

  8.   

    在delphi6.0中用adoquery控件如何实现这种效果?