BUG: SQL-DMO Treats Shutdown Message from SQL Server as Error Condition After Shutdown Method Runs (272145)
The information in this article applies to:
- Microsoft SQL Server 7.0 Service Pack 2
- Microsoft SQL Server 2000 (all editions)
This article was previously published under Q272145
BUG #: 58224 (SQLBUG_70)
BUG #: 235446 (SHILOH)
SYMPTOMS
You can use the SHUTDOWN method for the SQL Distributed Management Objects (SQL-DMO) server object to shut down the SQL Server service. The following message is sent back to SQL-DMO from the SQL Server server:
Server shut down by request.
SQL Server is terminating this process
SQL-DMO treats this as an error condition. However, SQL-DMO should not treat this as an error condition because shutting down SQL Server is the expected result. If you do not handle this error condition in the Microsoft Visual Basic application, the standard error message dialog box opens. After you acknowledge the error message, the application terminates
immediately, which may not be behavior you expect and may also produce unfavorable results.
Another error message that might occur is:
Error number: -2147215802
Error source: Microsoft SQL-DMO (ODBC SQLState: 01000)
WORKAROUND
By adhering to good programming practices and making sure that error conditions are handled within the Visual Basic code, you can prevent the unexpected termination of the application. Additionally, even after the error condition is handled, the SQL-DMO SQL Server object is still connected to the SQL Server server that shut down. Thus, it is necessary to run the Disconnect method if you want to reuse the object. If you do not need the object, to release the object you can set the object to Nothing.
Here is an example:
On Error GoTo errHandler
Set oSQLServer = New SQLDMO.SQLServer
oSQLServer.LoginSecure = True
oSQLServer.Connect ' Need to connect to SQL Server first
oSQLServer.Shutdown ' Execute shutdown
oSQLServer.DisConnect ' Disconnect from SQL Server if object is to be reused
:
' Rest of code. Without error handling, application will not get here
:
Set oSQLServer = Nothing 'Done
errHandler:
:
' Error handler
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 7/13/2004 |
---|
Keywords: | kbBug kbCodeSnippet kbpending KB272145 |
---|
|