Code Snippet
partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
string connstr = "Persist Security Info=False;Integrated Security=SSPI;" +
"Initial Catalog=Northwind;server=localhost";
SqlConnection conn = new SqlConnection(connstr);
string sql = "SELECT CompanyName,Address From Customers";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds, "Customers");
//
System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument(ds);
// your stuff with the xml
}
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your service.
}