using System;
using System.Data;
using System.Data.SqlClient;
public class SaveDiffGram
{
private static string connectionString = "Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI";
public static void Main()
{
string SQL = "SELECT TOP 3 CategoryID, CategoryName, Description FROM Categories";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand com = new SqlCommand(SQL, con);
SqlDataAdapter adapter = new SqlDataAdapter(com);
DataSet ds = new DataSet("Nortwind");
con.Open();
adapter.FillSchema(ds, SchemaType.Mapped, "Categories");
adapter.Fill(ds, "Categories");
con.Close();
DataRow row = ds.Tables["Categories"].Rows[0];
row["CategoryName"] = "Computer";
row["Description"] = "Java, Oracle";
ds.Tables["Categories"].Rows[1].Delete();
row = ds.Tables["Categories"].NewRow();
row["CategoryName"] = "Tools";
row["Description"] = "JUnit";
ds.Tables["Categories"].Rows.Add(row);
ds.WriteXml("mydata.xml" , XmlWriteMode.DiffGram);
ds.WriteXml(Console.Out , XmlWriteMode.DiffGram);
}
}