本人的 Clientdataset+Datasource+dbgrid,
想要把所有 applyupdate 过的记录写入一个 history table 里面,而且是根据 fieldname 与对应的修改值来insert的。请教高手,应该在哪一个事件里面写,应该怎么写?给一段code参考一下,谢谢。

解决方案 »

  1.   

    在applyupdate里写,你把delta指定给另一个clientdateset的data属性值,就可以看到修改过的数据是什么了。在李维的delphi5.x分布是多层应用系统篇里讲到delta的使用。
    这是ClientDataSet关于Delta属性的说明。
    Use Delta to pass a packet of change log data from the client dataset to a provider. Delta contains only information about those records inserted, modified, or deleted through the client.When the client dataset is linked to a provider, Delta is passed as an argument to the ApplyUpdates and Reconcile methods, which use the information in the change log to update the database. On return from successful application of updates, Delta is cleared. If update errors occur, the value of Delta after applying updates depends on the error tolerance allowed by the client dataset. This value isAll change log data when the maximum number of tolerated errors is encountered and all changes are rolled back.
    Only those changes that could not be applied when fewer errors occurred than the maximum specified as a tolerance level.In file-based applications, Delta is cleared when the changes are merged into the Data property using the MergeChangeLog method.
      

  2.   

    上面说了,Delta是个其极好用的数据包
      

  3.   

    我试了一下,将 tempCDS.data := Clientdataset1.delta;
    这样的确可以获得修改的 dataset,可是问题来了,我怎么判断这个 dataset 哪一条记录是 delete,append,还是 update 产生的呀?
      

  4.   

    大家难道没有人做过 log histoy 之类的?给点儿提示啊!
      

  5.   

    回复人: leejiey(李杰) ( ) 信誉:100  2004-11-10 18:10:00  得分: 0  
     
     
       上面说了,Delta是个其极好用的数据包
     
    呵呵,自己用这个,自己写的书当然说好螺,^_^
    我没有做过这个,不过如果我做的话,我会定义接口来完成操作,象一般的数据操作一样
      

  6.   

    to zdq801104(我很笨,但是我不傻!),帮忙给一个例子吧,我做的程序就差这一部分了。交不了差,就惨咯。