I have a very similar code to this to duplicate a TADODataSet component and it's events.
So, If I have an ADODataSet1 I want to create a new instance ADODataSet2 as exact duplicate component of the former component.
Everything works fine, But still I'm unable to duplicate the streaming fields (ADODataSet1PollID, ADODataSet1Title, ADODataSet1Description):
object ADODataSet1: TADODataSet
Connection = ADOConnection1
CursorType = ctStatic
AfterOpen = ADODataSet1AfterOpen
CommandText = 'select top 10 * from Polls'
Parameters = <>
Left = 224
Top = 40
object ADODataSet1PollID: TGuidField
FieldName = 'PollID'
FixedChar = True
Size = 38
end
object ADODataSet1Title: TWideStringField
FieldName = 'Title'
Size = 255
end
object ADODataSet1Description: TWideStringField
FieldName = 'Description'
Size = 4000
end
end
Another problem I'm having is that if ADODataSet1 set to Active=True, then when I call ms.ReadComponent(Dest), Active streams before Connection and that raises an Exception "Missing Connection or ConnectionString". How can I set Active to False after I write ms.WriteComponent(Source)? (A workaround is to set ADODataSet1.Active := False before duplicating it).
Note: I do not want to clone the cursor/recordset on dataset (TADODataSet.Clone) so please don't consider it as "duplicate question".