BDE 的有缓存更新的设计,可以自己获得字段缓存的值;ADO 如何实现?有什么好的组件吗??最好给我提供一个例子,我得从BDE转到ADO ,急需这方面的参考!谢谢!另外,ADO 的方法我晓得一个,就是用事务锁定表,然后用静态光标可以实现,但是这样老是错误百出,基本上出错率是20%以上;请高手帮帮忙,解决小弟燃眉之急!分不够另开帖子再加,我一直提问都是100分以上,但能解决的帖子少只又少,所以这帖不高,但我保证解决问题理解加分!

解决方案 »

  1.   

    你可以去看看李维的那本《Delphi5.x ado/mts/com+高级程序设计》
      

  2.   

    AdoDataSet or AdoTable or AdoQuery:
    LockType := ltBatchOptimistic;保存時:
      AdoQuery1.UpdateBatch
      

  3.   

    to hnhb(不死鸟) ;书下载了,一时半会儿找不到什么头绪;
    to  DongXF(孔雀东南飞) :谢谢指路;有没有办法判断数据是Insert 还是Update 还是Delete 的?还有数据类型验证 ?bde 的可以这样搞,因为单据都是bde的,现在要做成ado的,很多地方感觉是障碍
      

  4.   

    因为表内许多字段是AS 为别名的,而且还有多个表;那么在提交的时候就要用SQL 更新表内数据;这怎么办?
      

  5.   

    不用再说UpdateBatch了;有没有办法判断数据是Insert 还是Update 还是Delete 的?还有数据类型验证 ?bde 的可以这样搞,因为单据都是bde的,现在要做成ado的,很多地方感觉是障碍
      

  6.   

    AdoQuery的Locktype属性设置为ltBatchOptimistic  
    更新用AdoDataset.UpdateBatch
      

  7.   

    if adoquery1.State = dsInsert then 
       ...    //数据在新增状态if adoquery1.State = dsEdit   then
       ...    //数据在编辑状态
      

  8.   

    以下摘自Delphi的帮助文件,你可参考一下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          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抯 NewValue property is accessed.
    dsOldValue Temporary state used internally when a field component抯 OldValue property is accessed.
    dsCurValue Temporary state used internally when a field component抯 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.
      

  9.   

    感谢大家的解答,我已经解决了这个问题,但方法没用 UpdateBatch; 因为毕竟我的DataSet是一个Query ,并且字段里许多都是通过 AS 或是动态产生的单据字段;如果用ADO 的内置方法UpdateBatch的话,也没什么好结果,BDE 的可以做到;因为一个是缓存更新,一个是提交的时候可以判断处理并生成SQL而不是用Query的Post;
    好了,不用它,希望这里的人解决实际问题时能多提供几种方案。