|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
saving changes to XML doc
Ok there's the code. I get an error, Saving Token in state Epilog would result in an invalid XML document. WTF? haha.
what i do is read the document, take the last row, read the id, increment it and use it for the id of a new row, build the new row, add it, commit the changes to the data table and data set, then write the xml back to the file. help. DataSet myDs; DataTable myDt; DataRow myDr; int intNxtIndex; try { myDs = new DataSet(); myDs.ReadXml(Server.MapPath("../dna/data/dna.xml")); //Table1.Visible = false; Table2.Visible = false; myDt = myDs.Tables["store"]; myDr = myDt.Rows[myDt.Rows.Count-1]; intNxtIndex = System.Convert.ToInt16(myDr["id"]) + 1; myDr = null; myDr = myDt.NewRow(); myDr["id"] = intNxtIndex; myDr["storeDomain"] = Request.Form["txtDomain"]; myDr["storeName"] = Request.Form["txtStoreName"]; myDr["mstrEmail"] = Request.Form["txtMstrEmail"]; myDr["dbAddress"] = Request.Form["txtDbAddr"]; myDr["dbType"] = Request.Form["txtDbType"]; myDr["dbUser"] = Request.Form["txtDbUser"]; myDr["dbPass"] = Request.Form["txtDbPass"]; myDr["dbName"] = Request.Form["txtDbName"]; myDr["SSL"] = Request.Form["SSL"]; myDt.Rows.Add(myDr); myDt.AcceptChanges(); myDs.AcceptChanges(); myDs.WriteXml(Server.MapPath("../dna/data/dna.xml")); Response.Write("Document Saved."); } |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > saving changes to XML doc |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|