While trying to converting a datatable data to xml through stringwriter. It si giving outof memory exception.
My datatable contains about 20000 records.
Below is the code I am trying
DataTable dt = GetData();// contains 20000 records.
StringWriter sw = new StringWriter();
dt.WriteXml(sw);
XmlDocument sd = new XmlDocument();
sd.LoadXml(sw.ToString());
Can someone help me please.
You could try using a file stream instead of string writer.