Page 1 of 1

ADOQuery.Clone,How to realize

Posted: Mon 30 Mar 2009 11:50
by cxg417
My English is very poor!
ADOQuery.Clone,How to realize
________
Alaska Dispensary

Posted: Wed 01 Apr 2009 07:56
by Plash
You can use the TVirtualTable component. Copy data from TUniQuery to TVirtualTable using the TCRBatchMove component. Or save data to a file using the TUniQuery.SaveToXML method, and then load it to TVirtualTable using its LoadFromFile method.

Posted: Fri 03 Apr 2009 09:00
by cxg417
The loadfromxml method is so slowly! and,crbatchmove have not 'bmCopy'
________
Universal Health Warehouse

Posted: Mon 06 Apr 2009 08:23
by Plash
The default Mode of CRBatchMove - bmAppend - adds all data from one dataset to another. What should the bmCopy you are talking about do?

Re: ADOQuery.Clone,How to realize

Posted: Mon 06 Jun 2022 12:37
by Pavel95
I have similiar porblem, and tried your suggestion with TCRBatchMove. :

CRBatchMove1.Mode := bmAppend;
CRBatchMove1.Source := UniQuery1;
CRBatchMove1.Destination := VirtualDataSet1;
CRBatchMove1.Execute;

But i get Error like this on Execute:
The OnGetRecordCount event handler is not specified'.

When i implement just empty event OnGetRecordCount on VirtualDataSet1, i get no errors, but nothing happens - none data were copied.

Re: ADOQuery.Clone,How to realize

Posted: Fri 01 Jul 2022 12:31
by pavelpd
Hi Pavel,
Thanks for your request.

TVitrualDataSet component is not designed to copy data. It doesn’t store data in memory.
Its task is to interact with data through event handlers.
It can be used to represent of arbitrary data (arrays, lists etc.) in tabular form.
You can find a more detailed description of the TVitrualDataSet component in our online documentation:
https://docs.devart.com/virtualdac/deva ... ataset.htm


To copy data, use the TVirtualTable component instead of the TVitrualDataSet component.
The TVirtualTable component represents an in-memory data storage that does not have linked data files.
TVirtualTable allows to load data from a XML file, or from an existing dataset, and then process the data in the usual way, as in any TDataSet descendant.
An example of using TCRBatchMove to copy data from TUniQuery to TVirtualTable:

Code: Select all

uses
  ... , CRBatchMove;

  ...
var
  CRBatchMove: TCRBatchMove;
  UniQuery: TUniQuery;
  VirtualTable: TVirtualTable;
  ...
begin
  ...
  CRBatchMove := TCRBatchMove.Create(nil);
  try
    CRBatchMove.Source := UniQuery;
    CRBatchMove.Destination := VirtualTable;
    CRBatchMove.Execute;
  finally
    CRBatchMove.Free;
  end;
  ...
end;