Mega Code Archive

 
Categories / C# Tutorial / ADO Net
 

SqlXmlCommand and Xsl

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()         {             string strConn = @"Provider=SQLOLEDB;server=.\sqlexpress;database=northwind;integrated security=SSPI";             SqlXmlCommand cmd = new SqlXmlCommand(strConn);             cmd.CommandText = "select EmployeeID,FirstName,LastName from employees for xml auto";             cmd.RootTag = "root";             cmd.XslPath = Application.StartupPath + @"\employees.xslt";             StreamWriter writer = File.CreateText(Application.StartupPath + @"\sqlxmlresults.htm");             cmd.ExecuteToStream(writer.BaseStream);             writer.Close();                      }     }