Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataTable Rows ToString chopping long strings

Status
Not open for further replies.

gdrenfrew

Programmer
Aug 1, 2002
227
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top