How create xml schema for data table or dataset in csharp

Using below example we can create XML schema for dataset or data table.

ds.GetXmlSchema() is the important function to do this activity

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace convert_datatable_to_xml
    class Program
        static void Main(string[] args)
            //creating datatable
            DataTable dt = new DataTable("Employ");
            //adding columns to datatable

            //adding rows to datatable
            dt.Rows.Add("1", "ranga");
            dt.Rows.Add("2", "rajesh");

            //creating dataset
            DataSet ds = new DataSet("Employ_Details");
            //adding datatable to dataset
            //showing dataset value into XMLschema format. 


If you have any queries or suggestions, please feel free to ask in the comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar