A problem in restarting the service of MSSQLSERVER
I had the following problem in my application.
I need to Restart MSSQLServer service before do the connection test. In some cases, I have to Restart the MSSQLSERVICE again after connection test. In the old version of MSDE2000, no problem occured at all. But in MSDE2000 SP3a, I got the following error when restart the MSSQLSERVICE for a 2nd time.
But if I run the test program so as to execute RESTART and CONNECTIONTEST in pair each time, no error occured.
Can somebody give some advice to avoid this problem ?
Thank you!
The error log says :
2007-01-11 10:30:26.45 server Using 'SSNETLIB.DLL' version '8.0.766'.
2007-01-11 10:30:26.46 spid5 Starting up database 'model'.
2007-01-11 10:30:26.51 server SQL server listening on .
2007-01-11 10:30:26.53 server Error: 17826, Severity: 18, State: 1
2007-01-11 10:30:26.53 server Could not set up Net-Library 'SSNETLIB'..
2007-01-11 10:30:26.53 server Unable to load any netlibs.
2007-01-11 10:30:26.53 server SQL Server could not spawn FRunCM thread.
The test sources is:
private void RestartSQLServer()
{
ServiceController service = new ServiceController("MSSQLServer");
// Stop SQL service
if(service.Status.Equals(ServiceControllerStatus.Running))
{
RestartResult.Text = @"Stopping SQLServer...";
RestartResult.Refresh();
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped);
}
// Start SQLServer service
if(service.Status.Equals(ServiceControllerStatus.Stopped))
{
RestartResult.Text = @"Starting SQLServer...";
RestartResult.Refresh();
service.Start(); <= error occured at the 2nd restart
service.WaitForStatus(ServiceControllerStatus.Running);
}
}
private void ConnectTest()
{
// Get connection string
String connectString = (String)(MyTestRegistry.GetValue(ConnectionValueName));
// Creat database reference
SqlConnection testConnection = new SqlConnection(connectString);
try
{
// 3.Open & Close connection to database
testConnection .Open();
testConnection.Close();
}
catch
{
}
}
private void button_Clicked(object sender, System.EventArgs e)
{
RestartSQLServer();
ConnectionTest();
RestartSQLServer();
}

