Delphi – How to convert TCLIENTDATASET to another TCLIENTDATASET?

How to get changes from TClientDataset?

I have a TClientDataset called GetDataset and I have a grid. I want to make changes in a new TClientDataset called ChangeDataset.

How can I do it To this point?

If you source ClientDataSet CDS1, you should be able to copy the changed records to the second ClientDataSet CDS2

if CDS1.ChangeCount> 0 then 
CDS2.Data := CDS1.Delta;

As you will As you can see, it will provide you with “before” records and records with changes. This may not necessarily be what you want – frankly, you’d better read the reviews and Whipple articles published in OLH to get The exact result you may wish to achieve. The key is that all the information you need is in the source CDS until you clear it (by calling ApplyUpdates()-afterwards, if successful, the change log is empty).

If you look at the lines in CDS2, you don’t know how to tell whether a particular field contains a changed value, and how to distinguish a blank one. A long time ago, Istr was in a Borland in his Mark Terdington There is a very good post in the NTTP newsgroup, I think, explaining how to do this. Basically, this is a question of evaluating VarIsClear on the NewValue property of the field:

if VarIsClear(CDS2.Fields[i].NewValue) then 
// means Fields[i] does not have a changed value

By the way, because you can save the state of CDS It is XML, so you can use XML operations. For example, using a DOM parser, such as the built-in Windows (see MSXML.Pas), can easily accomplish many troublesome things using the TDataSet example.

How to get changes from TClientDataset?

I have a TClientDataset called GetDataset and I have a grid. I want to make changes in a new TClientDataset called ChangeDataset.

How can I do it To this point?

If you source ClientDataSet CDS1, you should be able to copy the changed records to the second ClientDataSet CDS2 by executing

if CDS1.ChangeCount> 0 then 
CDS2.Data := CDS1.Delta;

As you will see, it will provide you with “before “Records and records with changes. This may not necessarily be what you want – frankly, you’d better read the comments and Whipple articles published in OLH to get the exact results you might want to achieve. The point is, you All the information needed is in the source CDS until you clear it (by calling ApplyUpdates()-after that, if successful, the change log is empty).

If you look at the line in CDS2, You don’t know how to tell if a particular field contains a changed value, and how to distinguish one that is only empty. A long time ago, Istr had a very good post in a Borland NTTP newsgroup in his Mark Terdington, I Think, explain how to do this. Basically, this is a question of evaluating VarIsClear on the NewValue property of the field:

if VarIsClear(CDS2.Fields[i].NewValue ) then 
// means Fields[i] does not have a changed value

By the way, since you can save the state of CDS as XML, you can use XML operations, for example, use A DOM parser, such as the built-in Windows (see MSXML.Pas), can easily accomplish many troublesome things using the TDataSet example.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3134 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.