Use StreamWriter to read result from SqlXmlCommand : SqlXmlCommand « ADO.Net « C# / CSharp Tutorial






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);
            }
        }
    }








32.30.SqlXmlCommand
32.30.1.Save result from SqlXmlCommand to xml file
32.30.2.Using SqlXmlParameter
32.30.3.SqlXmlCommand and Xsl
32.30.4.Use StreamWriter to read result from SqlXmlCommand