Help With Windows Service

C

Charles A. Lackman

Hello,

I wrote a Windows Service is VB.NET and it works like clock work every
night. The problems is that the driver I am using to connect to a
datasource become inactive at a period of time. I destroy all it's
dependencies and recreate the connection every time the Windows Service
needs to retrieve the required data. In spite of my efforts to create a new
connection to the datasource, I continually receive a communication error on
or about the 3 or 4 day (the data is retrieved every night).

The only way I have been able to get the data to pull (after I receive the
communication error) is to restart the Windows Service.

Is there a way to make the Windows Service Restart itself?

i.e..

Try

AConnection.Open
ACommand.ExecuteNonQuery
AConnection.Close
AConnection.Dispose

Catch Err as Exception
WriteToLogFile(Err.ToString)
AConnection.Close
AConnection.Dispose
Me.Restart

End try

I Found Code To Stop The Service, but once it's stopped, then how would I
start it.

Dim scm As New ServiceController(Me.ServiceName)
scm.Stop()

Chuck
 
A

Alvin Bruney [MVP]

Can you check to see if you have a connection leak? make sure that you have
not exhausted your connections to the datasource by using a trace on the
datasource.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top