Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i want to convert sql server 2008 table convert to xml file.please send me details.
advance thanks
Posted

 
Share this answer
 
C#
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constring"].ConnectionString);
       if (con.State == ConnectionState.Closed)
       {
           con.Open();
       }
       SqlCommand cmd = new SqlCommand("select name ,user_code from tbl_user ", con);
       SqlDataAdapter da = new SqlDataAdapter(cmd);
       DataSet ds = new DataSet();
       da.Fill(ds);
       ds.Tables[0].WriteXml(@"D:\text.xml");

       if (con.State == ConnectionState.Open)
       {
           con.Close();
       }
 
Share this answer
 
Dataset have WriteXml method to serve your purpose. Fill your dataset and use that method. King_fisher example will work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900