using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlXml;
using System.IO;
public class MainClass
{
public static void Main()
{
try
{
string strConn = @"Provider=SQLOLEDB;server=.\sqlexpress;database=northwind;integrated security=SSPI";
SqlXmlCommand cmd = new SqlXmlCommand(strConn);
cmd.CommandText = "select * from employee";
StreamWriter writer = File.CreateText(Application.StartupPath + @"\sqlxmlresults.xml");
cmd.ExecuteToStream(writer.BaseStream);
writer.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
|