Microsoft KB Archive/231985

= PRB: Info Message Is Not Appended to ADO Errors Collection =

Article ID: 231985

Article Last Modified on 3/14/2005

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.1 Service Pack 2
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7

-



This article was previously published under Q231985



SYMPTOMS
The InfoMessage event of the connection object in ActiveX Data Objects (ADO) fires only when there is at least one Informational Message that resulted while establishing a connection to a database server. When opening an Asynchronous ADO connection, even if an InfoMessage event fires, no errors are appended to the Errors collection. In other words, the Errors collection is empty although there are one or more Info messages. If you open a synchronous connection, all Info Messages are appended to the Errors collection.



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



MORE INFORMATION
Connection and Recordset objects have events associated with them. While establishing a connection to most database servers the ODBC driver returns one or more Informational messages. These messages generally have a lower error severity level (usually below 10).

The following sample code establishes a connection to SQL Server, Synchronously and Asynchronously, using Visual Basic code. The Errors collection shows two Info Messages for Synchronous connection while it shows none for an Asynchronous connection.

Steps to Reproduce Behavior
 Start standard project in Visual Basic 6.0. Add a reference to the Microsoft ActiveX Data Objects Library. Add one command button to the default form.  Paste the following code in the form: Option Explicit

Dim WithEvents Cn As ADODB.Connection

Private Sub Cn_InfoMessage(ByVal pError As ADODB.Error, _                                adStatus As ADODB.EventStatusEnum, _                                 ByVal pConnection As ADODB.Connection)

If pConnection.Errors.Count > 0 Then For Each pError In pConnection.Errors MsgBox pError.Description Next Else MsgBox "The error collection is empty" End If

End Sub

Private Sub Command1_Click

Dim CnStr As String Dim i As Integer

Set Cn = New ADODB.Connection

CnStr = "Driver={SQL Server};Server=;" & _ "UID=;PWD="

Cn.Open CnStr  ',, , adAsyncConnect

For i = 1 To 100 DoEvents Next

MsgBox "Connection is established"

End Sub

 Modify the connection string to match your server settings.</li> Run the project. Note that the informational messages display in a message box followed by a "Connection is established" message.</li> Uncomment the commented section of the Cn.Open line.</li> Run the project again and note that the following error occurs:

Connection is established.

</li></ol>

Keywords: kbbug kbdatabase kbprb KB231985

-

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

© Microsoft Corporation. All rights reserved.