With some slower machines running our application (which is located in the Windows startup folder) when the machine is restarted and autologized, the SQL Server service is still in a running state when my application is running. (SqlServer 2005)
What I did to counter this was to check the status of the service (MSSQL $ idealsql) and wait for the service to start.
Public Function isServiceRunning() As Boolean
Dim theServices() As System.ServiceProcess.ServiceController
Dim theservice As System.ServiceProcess.ServiceController
theServices = System.ServiceProcess.ServiceController.GetServices
Dim running As Boolean
For Each theservice In theServices
If String.Equals(theservice.ServiceName, mServiceName, StringComparison.OrdinalIgnoreCase) Then
running = (theservice.Status = ServiceProcess.ServiceControllerStatus.Running)
Exit For
End If
Next
Return running
End Function
This returns the correct result after the service arrives on the network, but SQLServer takes a little time before it is fully operational after the service starts.
.
.
( )
false →
true → , ..
( , ), , sysdatabases, , , , , .
TempDB , , , .
SELECT crdate AS StartTime FROM sys.sysdatabases WHERE name = 'tempdb'
EventVwr, TempDB - , .
, SQLServer , ?
- VB.Net, , , .