Re: Any TDataset to ADO?



Maybe I dont understand the question but try changing the tdataset to
tadodataset

I think I could have been more clear in my question.

The underlying database I use to get the TDataset is e.g. an kbmMemTable.
For an external tool (COM-based) I have to deliver an ADO Recordset. So I
have to fill an ADO Recordset with all records in my TDataset.

At the moment I am using a simple copy routine. First I create an in-memory
ADO recordstructure based on the TDataset structure. Afterwards I copy the
fields of the records one by one into the ADO Recordset.

This takes some time and some memory (all records exists twice). I am
looking for some optimization. Because the COM-component only needs read
access I thought about using pointers to share the TDataset data in memory.

The code below gives a good impression of what I'm doing right now (please
note: this is not the actual code):

function TForm1.ConvertDataSet(Source : TDataSet) : _RecordSet;
var
fldCount : integer;
begin
AdoDataSet := TAdoDataset.Create(Self);
AdoDataSet.FieldDefs.Assign(Source.FieldDefs);
AdoDataSet.CreateDataSet;
AdoDataSet.Active := True;

Source.First;
while not Source.Eof do
begin
AdoDataSet.Append;
for fldCount :=0 to AdoDataSet.FieldCount -1 do
AdoDataSet.Fields[fldCount].assign(Source.Fields[fldCount]);
AdoDataSet.Post;
Source.Next;
end;
RecordSet := AdoDataSet.RecordSet;
end;

Gert


.



Relevant Pages

  • Re: Which is faster--Array or ADO
    ... Any solution based on 'data lives in memory' is hardly multi-users friendly: if data change, you need to resych it, not necessary trivial. ... In fact, your "array" solution is close to the one I called ADONet, but you have to add the join mechanism, yourself, which can be easy, or very difficult, depending on your EXACT scenario. ... Loading 70k rows from a table into an ADO recordset and working with it ... Is the ADO recordset in RAM also? ...
    (microsoft.public.access.modulesdaovba)
  • Re: Damn you, FEDEX! or Nikon D40 lost in Springfield, MO blackhole.
    ... the 2 mp Mavica he had been using with a Nikon D40. ... After shopping around, he got me to order one for him. ... The shipper had it insured, but from what I have read it could take weeks to sort this crap out. ... You may get your insurance from FedEx and a couple weeks later they find it and deliver it. ...
    (alt.photography)
  • running out of memory
    ... I have to write custom data integrity utilities comparing files with table ... I've found that looping through an ado recordset will cause memory problems ... 'this loop is running out of memory ...
    (microsoft.public.data.ado)
  • running out of memory
    ... I have to write custom data integrity utilities comparing files with table ... I've found that looping through an ado recordset will cause memory problems ... 'this loop is running out of memory ...
    (microsoft.public.data.oledb)
  • running out of memory
    ... I have to write custom data integrity utilities comparing files with table ... I've found that looping through an ado recordset will cause memory problems ... 'this loop is running out of memory ...
    (microsoft.public.dotnet.framework.adonet)