Monday, 16 September 2013

Populating all data to an xml file from sql server

List<SelectListItem> UniversityType = new List<SelectListItem>();
            conCheck();
           
           
            SqlCommand cmd = new SqlCommand();


            cmd.Connection = sqlcon;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "insertUniversityType";
            cmd.Parameters.AddWithValue("@type", univType);
            //cmd.ExecuteNonQuery();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet dt = new DataSet();
            da.Fill(dt);
            sqlcon.Close();
           

            //---------populating xml
            string XMLFile1 =HttpContext.Current.Server.MapPath("~/XMLFiles/UniversityType.xml");
            dt.WriteXml(XMLFile1, XmlWriteMode.IgnoreSchema);
            //----------------------

No comments:

Post a Comment