Reputation: 27264
I have an app that runs on system startup that needs to talk to the local SQL Server 2005 installation. I'm using the ServiceController class to wait for it to enter the "Running" state, and most times this works fine. However, sometimes on a cold boot, my first query fails, saying that it couldn't log on the current user.
It sounds like a race condition, but I figured my WaitForStatus call was supposed to resolve it.
Is there a better way to make sure it's really-truly running? Should I just throw in an extra sleep and assume it's long enough?
Upvotes: 2
Views: 1153
Reputation: 4171
You could always use the System.Data.Sql.SqlDataSourceEnumerator and check for the local instance.
On the plus, you can also discover version information with the enumerator.
Upvotes: 3