Microsoft KB Archive/272145

= BUG: SQL-DMO Treats Shutdown Message from SQL Server as Error Condition After Shutdown Method Runs =

Article ID: 272145

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft SQL Server 7.0 Service Pack 2
 * Microsoft SQL Server 2000 Standard Edition

-



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



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
Prior to SQL Server 7.0 Service Pack 2, no error condition was generated. Following is the version information of the SQL-DMO files for SQL Server 7.0 Service Pack 2:

Additional query words: hang response waits

Keywords: kbbug kbcodesnippet kbpending KB272145

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.