using System;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Xml;
public class MainClass{
public static void Main(string [] args) {
DataSet dataSet = new DataSet("Product");
SqlConnection connection = new SqlConnection("Initial Catalog=Product; Integrated Security=SSPI; User ID=sa");
string command = "SELECT name, p_date FROM employee";
SqlDataAdapter adapter = new SqlDataAdapter(command, connection);
connection.Open();
adapter.Fill(dataSet, "myEmployee");
connection.Close();
XmlDataDocument doc = new XmlDataDocument(dataSet);
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting = Formatting.Indented;
doc.WriteTo(writer);
}
}
|