BUG: T-SQL PRINT Statement May Not Show as Informational Error (294178)
The information in this article applies to:
- ActiveX Data Objects (ADO) 2.0
- ActiveX Data Objects (ADO) 2.01
- ActiveX Data Objects (ADO) 2.1
- ActiveX Data Objects (ADO) 2.1 SP1
- ActiveX Data Objects (ADO) 2.1 SP2
- ActiveX Data Objects (ADO) 2.5
- ActiveX Data Objects (ADO) 2.6
- ActiveX Data Objects (ADO) 2.7
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP3
- Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP4
- Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP5
- Microsoft Visual Basic Professional Edition for Windows 6.0
This article was previously published under Q294178 SYMPTOMS You can use Microsoft SQL Server's PRINT statement in
stored procedures to return messages as informational errors in ADO, OLE DB,
and ODBC applications. However, a Visual Basic client application may not
capture such informational messages when it sets up a DataEnvironment command
and uses the DataEnvironment.CommandName syntax to run the stored procedure. CAUSE This problem has its roots in ADO. The InfoMessage event of an ADO Connection object does not fire when its CursorLocation property is set to adUseClient. By default, the CursorLocation property of Visual Basic 6.0 DataEnvironment Connection objects is set to adUseClient. As a result, the InfoMessage event procedure of DataEnvironment Connection objects does not fire when informational messages are returned to
the client application. RESOLUTION There are two ways to work around this problem:
- Set the CursorLocation property of the DataEnvironment Connection object to adUseServer, and use an ADO Recordset object to run the DataEnvironment Command setup, which runs the SQL Server stored procedure. When you use
the DataEnvironment.CommandName syntax to run the command, the InfoMessage event is not raised, even if the DataEnvironment Connection object's CursorLocation property is set to adUseServer.
- Use straight ADO code to run the stored procedure. When you
use straight ADO code, make sure that the CursorLocation of the ADO Connection object is not set to adUseClient.
See the "More Information" section for sample code that
illustrates these two workarounds. STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed at the beginning of this article.
REFERENCES For additional information about using the InfoMessage event and ADO, click the article numbers below to view the
articles in the Microsoft Knowledge Base:
231985 PRB: Info Message Not Appended to ADO Errors Collection
194792 HOWTO: Retrieve Values in SQL Server Stored Procedures with ADO
Modification Type: | Minor | Last Reviewed: | 7/15/2004 |
---|
Keywords: | kbBug kbDatabase kbpending KB294178 |
---|
|