Click here to Skip to main content
15,910,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to retrive the data from the database in windows services and dump it in another table.
how to di this ..
help me..
Posted

1 solution

you can do like this...
C#
public 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.

        }



See this for more info...
http://social.msdn.microsoft.com/Forums/en-US/winformsapplications/thread/f9dd9b7d-2240-40af-86ea-33e241451d9f[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900