In many applications, Windows services need to be done to operate the database, such as (1) some very slow database operations, do not want to do one-time, want to do slowly through the service, such as database backup, etc. (2) Using Windows services in .NET Remoting to do Host use vs.net we can build its Windows service within a few minutes, very simple to talk about step 1. Creating a new item 2. Select Windows from a list of available project templates Services 3. Designer opens in design mode 4. Drag a Timer object from the component table from the toolbox to this design surface (Note: Make sure to use Timer from the list of components instead of the WINDOWS form "5 . Set the Timer property, the Interval property 200 milliseconds (5 database operations in 1 second) 6. Then fill in the function for this service 7. Double-click this Timer, then write some database operations, such as SqlConnection conn = new SqlConnection "Server = 127.0.0.1; database = test; uid = sa; pwd = 275280"); sqlcommand comm = -new SQLCOMMAND ("INSERT INTO TB1 ('111', 11)", conn); conn.open (); Comm.executenonQuery (); conn.close (); 8. Switch this service program to the design view 9. Right-click the design view to select "Add Setup" 10. Switch to the design view of the ProjectInstaller that is just added. 11. Sets ServiceInstaller1 Component's attributes: 1) ServiceName = my sample service 2) StartType = Automatic (boot automatic run) 12. Set the properties of ServiceProcessInstaller1 components Account = localsystem13. Change the path to your project's BIN / Debug folder location (if you take Release Mode compiling is in bin / release folder) 14. Run "installutil.exe myWindowsservice.exe" Register this service so that it creates a suitable registration item. (InstallUTIL This program is below Windows folder / microsoft.net/framework/v1.1.4322) 15. Right click on "My Computer" on the desktop, select "Manage" to make a computer management console 16. Service and application In the "Services" section inside the program, you can find that your Windows service is already included in the service list. 17. Right-click your service to choose to start, you can start your service. Take a look at the database. Record, you need to pay attention to: If you modify this service, if you don't change, you don't need to re-register the service. If the path changes, you need to uninstall this service installil.exe / u parameter, then reinstall this Service, you can't install it. There is also the Windows service is no interface, do not try to output some information with the output mode of the control, you can only add an EventLog, write the log through WriteEntry (). You can look at how to use Windows service to do a remote service http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/setht15.asp