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();
}

[2427 byte] By [BobSun] at [2007-12-28]
# 1
What do you see in the Windows System Event Log?
PaulPClementIV at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2

Paul P Clement IV wrote:

What do you see in the Windows System Event Log?

I got three error events and 1 normal event:

1.SuperSocket info: ConnectionListen(Shared-Memory (LPC)) : Error 5.
2.Error: 17826, Severity: 18, State: 1 Could not set up Net-Library 'SSNETLIB'.
3.19013 :SQL server listening on . (this is INFORMATION event)
4.17120 :SQL Server could not spawn FRunCM thread.

Can you give me some advice?

Thank you.

BobSun at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 3


See if the following helps:

http://tinyurl.com/aea8a

PaulPClementIV at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified