[RESOLVED] Setting the priority of start-up application/service
I have an app which auto-starts and connects to sql server but the thing is I am not sure if the sql server is started first and from time to time my app encounters an error wherein it cannot connect to the sql server, I would assume it is because sql server hasn't fully started yet or that my application started first, is there something I could do so that my app will wait for sql server to start before connecting?
TIA
Re: Setting the priority of start-up application/service
Okay, this is how I am checking if SQL Server instance is already started before I try connecting to it.
Code:
Public Function SQLServerIsStarted() As Boolean
Dim Process As Object
SQLServerIsStarted = False
For Each Process In GetObject("winmgmts:").ExecQuery("Select * from Win32_Process WHERE Caption = 'sqlservr.exe'")
SQLServerIsStarted = True
Next
End Function
Re: [RESOLVED] Setting the priority of start-up application/service
You could also just check to see if the Microsoft SQL Server service is started using the System.ServiceProcess.ServiceController class couldnt you? (I dont like WMI :D)
Re: [RESOLVED] Setting the priority of start-up application/service
Quote:
Originally Posted by
chris128
You could also just check to see if the Microsoft SQL Server service is started using the System.ServiceProcess.ServiceController class couldnt you? (I dont like WMI :D)
Its for VB6. :) But thanks for the info.
Re: [RESOLVED] Setting the priority of start-up application/service