Access violation when loading a TClientDataset from XML

Hi

I have a TClientdataset instance that has been saved to a string (using the SaveToStream method).
When I load the string back into another TClientDataset instance I get an access violation in midas.dll at address 0018DDD6, read address 00000000.

The xml I am loading is as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> BillingRunID="21798" FromDateTime="20230831" ToDateTime="20231111T23:59:59999"

Has anyone got any ideas on how to fix this problem.

I am currently running Delphi 11 Version 28.44500.8973 and Windows 10 version 22H2 OS build 19045.3570 64-bit)

To get the error, drop a TClientDataset on a form, right-click the icon and chose ‘Load from MyBase table’. The file to choose is an xml file using the above text.

Regards
Graeme

Seems as though some of my xml is missing.

I have attached it below
ADUG CDS.LoadFromStream problem.zip (579 Bytes)

When posting code or markup, you need to tell discourse what it is, to do that add a line with 3 backtics and then the language (for highlighting) and the end it with 3 backticks on a separate line

```xml
code/xml goes here
```

I formatted it for easier reading (original had no line breaks).

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DATAPACKET Version="2.0">
	<METADATA>
		<FIELDS>
			<FIELD attrname="QueueIDs" fieldtype="nested">
				<FIELDS>
					<FIELD attrname="QueueID" fieldtype="i8"/>
					<FIELD attrname="LINK_FIELD" fieldtype="ui4" hidden="true" linkfield="true"/>
				</FIELDS>
				<PARAMS CHANGE_LOG="1 0 4"/>
			</FIELD>
			<FIELD attrname="BillingRunID" fieldtype="i8"/>
			<FIELD attrname="FromDateTime" fieldtype="dateTime"/>
			<FIELD attrname="ToDateTime" fieldtype="dateTime"/>
			<FIELD attrname="ClientIDs" fieldtype="nested">
				<FIELDS>
					<FIELD attrname="ClientID" fieldtype="i8"/>
					<FIELD attrname="Successfull" fieldtype="boolean"/>
					<FIELD attrname="ResultInfo" fieldtype="bin.hex" SUBTYPE="Text"/>
					<FIELD attrname="LINK_FIELD" fieldtype="ui4" hidden="true" linkfield="true"/>
				</FIELDS>
				<PARAMS CHANGE_LOG="1 0 4"/>
			</FIELD>
		</FIELDS>
		<PARAMS CHANGE_LOG="1 0 4 1 2 64 1 1 64"/>
	</METADATA>
	<ROWDATA>
		<ROW RowState="4">
			<QueueIDs>
				<ROWQueueIDs RowState="4" QueueID="1" LINK_FIELD="1"/>
			</QueueIDs> BillingRunID="21798" FromDateTime="20230831" ToDateTime="20231111T23:59:59999"
			<ClientIDs>
				<ROWClientIDs RowState="4" ClientID="21555" LINK_FIELD="1"/>
			</ClientIDs>
		</ROW>
	</ROWDATA>
</DATAPACKET>

Thanks Vincent

I will try and remember your instructions for next time.

With respect to my problem it appears that the TClientDataset that has
nested datasets can use the SaveToFile/SaveToStream methods but cannot
load the resultant data using the LoadFromFile/LoadFromStream methods.

I am assuming that in order to use nested datasets a secondary
ClientDataset is required to store/use the nested dataset data.

In my case there is nested data but not CDS to store the data. Hence the
AV on address zero.

Regards
Graeme

Does XML Mapper help with this? I seem to remember doing something with nested xml data in the past.

https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_XMLMapper