database backup

Posted by Srivalli under ASP.NET on 7/21/2009 | Views : 1050 | Status : [Member] | Replies : 3
Good Day all

I have table names in a Dropdownlist and onselected index changed i want to Export the table contents to a XML File.

Thank you




Responses

Posted by: Vuyiswamb on: 7/21/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Morning Srivalli

Am always online, i see what you are saying. but i need more explanation. Let me help you interactively. You can use gmail or Skype

Gmail: vuyiswamb
Skype: vuyiswamb

Skype me, after you got the answer please come back to the forum and share the asnwer because someone might need it in the future.

Thank you forp posting at d0otnetfunda

Vuyiswa Maseko


Thank you for posting at Dotnetfunda
[Administrator]

Srivalli, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 7/22/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Use the Following Stored Procedure


CREATE PROC EXPORT_TO_XML
(
@TABLENAME VARCHAR(60),
@XML XML output
)
AS
set @XML = (SELECT *
FROM @TABLENAME
FOR
XML PATH(''), TYPE, ELEMENTS
)



This Sp will accept the name of the table and return a XML String and the Following code tells you where to save it in your local disk.


using System;

using System.Xml;

public class Sample {

public static void Main() {

// Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<item><name>wrench</name></item>");

// Add a price element.
XmlElement newElem = doc.CreateElement("price");
newElem.InnerText = "10.95";
doc.DocumentElement.AppendChild(newElem);

// Save the document to a file. White space is
// preserved (no white space).
doc.PreserveWhitespace = true;
doc.Save("data.xml");

}
}


Thank you for Posting in .NEt Funda

Thank you for posting at Dotnetfunda
[Administrator]

Srivalli, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 7/23/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
change your C# code and make it look this way

using System;


using System.Xml;



public class Sample {



public static void Main() {



// Create the XmlDocument.

XmlDocument doc = new XmlDocument();
//Here load a string of XML that is Comming from the SP
doc.LoadXml(XMLString);

// Save the document to a file. White space is

// preserved (no white space).

doc.PreserveWhitespace = true;
//here you can add a Path like "C:\Data.xml"
doc.Save("data.xml");

}

}


Thank you for Posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Srivalli, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response