separate dataset instances using datamodules in delphi

前端 未结 4 1925
小蘑菇
小蘑菇 2021-01-14 12:09

I am using Delphi6 and have a data module with an ADO DataSet which is used by two forms, formA and FormB. Each form has a Datas

4条回答
  •  梦毁少年i
    2021-01-14 12:58

    Are you trying to access the same dataset from FormA and FormB at the same time while displaying different data, if so:

    Use a TClientDataSet and a TDataSetProvider to load the data from you ADO dataset. Then clone the cursor using ClientDataSet.CloneCursor, you get a seperate cursor to the same data. Then pass them to the forms or assign the controls of FormA to ClientDataSetA and FormB to the clone ClientDataSetB. Reads, writes and updates from both forms change the underlying dataset which can then apply the updates to the database through the ADO dataset later via the DataSetProviders ApplyUpdates.

    Look here for some help: http://www.podgoretsky.com/ftp/docs/Delphi/D5/dg/5_ds3.html Or there is a really good book by Cary Jenson: http://www.jensendatasystems.com/cdsbook/ (free plug, but it is a good read)

提交回复
热议问题