Board index » delphi » transfering data from a clientdataset

transfering data from a clientdataset

Hi!

I have to do the following thing, make a clientdataset in one
form get all data from another clientdataset. I try to do
clientdataset1 := clientdataset2, but this instruction only
transfer the pointer, not the data and how I'm planning to
destroy the second clientdataset, an exception happens when I
try to access the data.
How can I do that????

tks.
Denilson

 

Re:transfering data from a clientdataset


If you're just providing another view to the data, you could just put a
datasource on the first dataset, and use it as the master for the second
dataset.

If you are trying to actually copy the data then
  ClientDataSet2.XMLData := ClientDataSet1.XMLData

Quote
"Denilson" <rode...@hotmail.com> wrote in message news:3d3d5bad$1_2@dnews...

> Hi!

> I have to do the following thing, make a clientdataset in one
> form get all data from another clientdataset. I try to do
> clientdataset1 := clientdataset2, but this instruction only
> transfer the pointer, not the data and how I'm planning to
> destroy the second clientdataset, an exception happens when I
> try to access the data.
> How can I do that????

> tks.
> Denilson

Re:transfering data from a clientdataset


The quickest way would be to copy the data from one dataset to the
other.  This just copies the data and not the calculated or lookup
fields.  The Data property is what TClientDataSet uses internally, so it
will probably be faster than using the XMLData property.

i.e. ClientDataSet2.Data := ClientDataSet1.Data.

If you also need the calculated and lookup fields, you can use a
TDataSetProvider.  Set the DataSetProvider's DataSet property to your
source ClientDataSet and set the destination ClientDataSet's
ProviderName property to the DataSetProvider.  When you open or refresh
the second ClientDataSet, it will refresh from the first ClientDataSet.

Note: The provider goes to every record in the source ClientDataSet to
get the values.  This can get slow if you have a lot of data aware
controls, so you might want to use DisableControls before you do a
Refresh, and re-enable them after.

I hope this helps.

Regards,
Bruce McGee

Quote
Denilson wrote:
> Hi!

> I have to do the following thing, make a clientdataset in one
> form get all data from another clientdataset. I try to do
> clientdataset1 := clientdataset2, but this instruction only
> transfer the pointer, not the data and how I'm planning to
> destroy the second clientdataset, an exception happens when I
> try to access the data.
> How can I do that????

> tks.
> Denilson

Other Threads