Atef
I thought about the issue here, and wrote a simple method which will write your datatable to xml. I will say that there is a lot of room for optimization in my method. But the idea is to get the ball rolling. I do wish that MS will have a WriteToXML method for the DataTables in the next version of the framework. Anyway here is what I wrote
public static void WriteToXML(DataTable dt, string fileName
//write the datatable to xm
string xml = "<?xml version=\"1.0\" standalone=\"yes\"?>"
xml += "<newDataSet></newDataSet>"
XmlDocument doc = new XmlDocument()
doc.LoadXml(xml)
XmlTextWriter xw = new XmlTextWriter(fileName,System.Text.Encoding.UTF8)
XmlElement rootElement = doc.DocumentElement
foreach(DataRow row in dt.Rows
XmlElement rowElement = doc.CreateElement("Table")
for(int i= 0; i < dt.Columns.Count; i++
XmlElement[] colElement = new XmlElement[dt.Columns.Count]
colElement = doc.CreateElement(dt.Columns.Caption)
colElement.InnerText = row.ToString()
rowElement.AppendChild(colElement)
rootElement.AppendChild(rowElement)
doc.WriteTo(xw)
xw.Close()
Regards
Deepa
[I Code, therefore I am
----- atef shehata wrote: ----
thanks Deepak for you help
l'm already using the same solution you mentioned
but in my situation ...
i have a dataset per each webform , each dataset holds many datatable
representing the queries data
this queries cached (on the server) as xml files(around 380 tables , some exceeds 2 million of records !!
so we can say , every datatable on the dataset can be cached accordin
to some generic parameters(lifetime and its expire date ,no. o
records ,...
after saving the xml file , in the same webform or another one th
cached data will be used (loaded into an intermediate dataset the
copied into the actual datatable in the actual dataset
so i want to avoid this extra step of copying the data from th
intermediate dataset to the actual dataset
any comments
thanks Deepak
ate