Re: Any TDataset to ADO?
- From: "Gert" <<ask for it>>
- Date: Fri, 25 May 2007 10:37:51 +0200
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
.
- Follow-Ups:
- Re: Any TDataset to ADO?
- From: Del Murray
- Re: Any TDataset to ADO?
- References:
- Re: Any TDataset to ADO?
- From: Del Murray
- Re: Any TDataset to ADO?
- Prev by Date: Re: OTHER BIG BUG : deleting detail master delete
- Next by Date: Re: Any TDataset to ADO?
- Previous by thread: Re: Any TDataset to ADO?
- Next by thread: Re: Any TDataset to ADO?
- Index(es):
Relevant Pages
|