using System;
using System.Windows.Forms;
//---------------------------------
using System.Data;
using System.Data.SqlClient;

namespace _ex_17_41
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection sCon = new SqlConnection(@"Server=.;
                                     DataBase=MyTestDB;
                                     Integrated Security=True");
            SqlDataAdapter sda = new SqlDataAdapter("Select * From Info",
                                     sCon);
            DataSet ds = new DataSet();
            sCon.Open();
            sda.Fill(ds, "table1");
            sCon.Close();

            ds.WriteXml(@"C:\MyTestDB.XML", XmlWriteMode.WriteSchema);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            ds.ReadXml(@"C:\MyTestDB.XML", XmlReadMode.ReadSchema);
            dataGridView1.DataSource = ds;
            dataGridView1.DataMember = "table1";
        }
    }
}