Hi,
A string of XML from the database appears to get chopped when it's put into a datatable, then extracted again with ToString(). How can I stop this? Thanks.
I am maintaining historical code which gets a string of XML from the SQL database (using FOR XML AUTO, ELEMENTS) eg "<Msgs><MsgID>1</MsgID><Txt>Something</Txt></Msgs><Msgs><MsgID>2</MsgID><Txt>SomethingElse</Txt></Msgs>", stores it in a DataSet in the DAL layer, then passes it back up to the BSL into and a DataTable.
Here it is then extracted thus: myDT.Rows[0][0].ToString()
Unfortunately, very long (1900chars) strings are concatenated - leading to the string being invalid XML.
I'm confused because it can get the full length of the XML using a dataset.
I have tried keeping the string in a dataset (ie not putting it into a datatablein the BSL), then using myDS.GetXml().ToString() which gets the entire length of the string, but also gets all the XML stuff like the GUID and "NewDataSet" elements. Which I don't want as there are too many other places where I'd have to change code to deal with these "extra" elements.
How can I ensure I get the full XML string out of a datatable? Is there a "correct way" to do this?
Thanks
A string of XML from the database appears to get chopped when it's put into a datatable, then extracted again with ToString(). How can I stop this? Thanks.
I am maintaining historical code which gets a string of XML from the SQL database (using FOR XML AUTO, ELEMENTS) eg "<Msgs><MsgID>1</MsgID><Txt>Something</Txt></Msgs><Msgs><MsgID>2</MsgID><Txt>SomethingElse</Txt></Msgs>", stores it in a DataSet in the DAL layer, then passes it back up to the BSL into and a DataTable.
Here it is then extracted thus: myDT.Rows[0][0].ToString()
Unfortunately, very long (1900chars) strings are concatenated - leading to the string being invalid XML.
I'm confused because it can get the full length of the XML using a dataset.
I have tried keeping the string in a dataset (ie not putting it into a datatablein the BSL), then using myDS.GetXml().ToString() which gets the entire length of the string, but also gets all the XML stuff like the GUID and "NewDataSet" elements. Which I don't want as there are too many other places where I'd have to change code to deal with these "extra" elements.
How can I ensure I get the full XML string out of a datatable? Is there a "correct way" to do this?
Thanks