Home > DeveloperSection > Articles > How to Create XML file of Database in C Sharp

How to Create XML file of Database in C Sharp


XML XML 
Ratings:
1 Comment(s)
 12126  View(s)
Rate this:

How to Create XML File of Database in C#.Net


To create XML file of Database we have to call WriteXml() function of Data Set.

Example

string strConnection = "Server=abc\\SQLEXPRESs;Database=Employee;Trusted_Connection=True";

            SqlConnection con = new SqlConnection(strConnection);

//creating new connection to database Employee

            con.Open();

//opening connection

SqlDataAdapter da = new SqlDataAdapter("select * from employee", con);

//assigning data to DataAdapter according to the query

            DataSet ds = new DataSet();

            da.Fill(ds, "Employee");

//filling dataset.

            ds.WriteXml("C:\\dataEmployee.xml");

//writing XML file of name ‘dataEmployee.xml’ of database

Screen shot


Thanks..

By Sushant Mishra on   one month ago

It was really helpful to read this post.


Don't want to miss updates? Please click the below button!

Follow MindStick