using System;
using System.Data;
using System.Xml;
using System.Data.OleDb;
using System.Data.SqlClient;
using Microsoft.Data.SqlXml;
namespace CSCommand
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
StartPoint();
}
static void ShowXmlInIE(string strPathToXml)
{
SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorerClass();
object objEmpty = Type.Missing;
ie.Navigate(strPathToXml, ref objEmpty, ref objEmpty, ref objEmpty, ref objEmpty);
ie.Visible= true;
}
public static void StartPoint()
{
string strConn, strSQL;
strConn = "Provider=SQLOLEDB;User ID=sa;Password=gatsol;Initial Catalog=NorthWind;Data Source=211.236.186.207;";
strSQL = "Select Top 2 CustomerID, CompanyName From Customers For Xml Auto, Elements";
SqlXmlCommand cmd = new SqlXmlCommand(strConn);
cmd.CommandText = strSQL;
cmd.RootTag = "ROOT";
XmlDocument xmlDoc = new XmlDocument();
XmlReader rdr = cmd.ExecuteXmlReader();
xmlDoc.Load(rdr);
rdr.Close();
string strPathToXml = "C:\\MyData.Xml";
xmlDoc.Save(strPathToXml);
ShowXmlInIE(strPathToXml);
}
}
}