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

string strConnection = "Server=abc\\SQLEXPRESs;Database=Employee;Trusted_Connection=True";
            SqlConnection con = new SqlConnection(strConnection);
//creating new connection to database Employee
//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.
//writing XML file of name ‘dataEmployee.xml’ of database
Screen shot

How to Create XML file of Database in C Sharp

  Modified On Sep-07-2019 12:10:59 AM

Leave Comment