Microsoft KB Archive/223068

= FIX: RDO InfoMessage Event Behavior Different in VB6 and VB5 =

Article ID: 223068

Article Last Modified on 11/5/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q223068



SYMPTOMS
When using RDO with Visual Basic 6.0, it is possible to declare the RDOEngine object WithEvents so that you can trap informational messages that are returned from the underlying ODBC driver. These messages will be raised in the RDOEngine_InfoMessage event.

When using RDO in a Visual Basic 6.0 application, you may see additional informational messages being raised through the RDOEngine_InfoMessage event under various circumstances. In these cases this event is being fired incorrectly.



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

This bug was corrected in Visual Studio 6.0 Service Pack 3.

For more information about Visual Studio 6.0 Service Packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed



MORE INFORMATION
The following code reproduces this problem. This code assumes that you are using SQL Server as your database. You will need to modify the connection string to point to your SQL Server.  Create a new Visual Basic 6.0 Project. Form1 is created by default. Set a reference to the Microsoft Remote Data Object 2.0 library. Add a CommandButton to the default form.  Place the following code in the default form:

Note You must change uid= and pwd= to the appropriate username and password before you run this code. Make sure that the changed uid has the appropriate permissions to perform the required operations on the specified database. Dim WithEvents rEngine As rdoEngine Dim cn As rdoConnection Const CONNECTSTR = "Driver={SQL Server};Server=(local);database=pubs;uid= ;pwd= "

Private Sub Command1_Click Set Query = New rdoQuery Query.SQL = "Begin transaction" & vbCrLf & "Rollback transaction" Set Query.ActiveConnection = cn   Query.Prepared = False Query.RowsetSize = 1 Query.Execute              '*** This line causes the informational message ***

End Sub

Private Sub Form_Load Set rEngine = RDO.rdoEngine Dim Query As rdoQuery Set cn = New rdoConnection cn.Connect = CONNECTSTR cn.EstablishConnection rdDriverNoPrompt End Sub

Private Sub rEngine_InfoMessage Dim myerr As rdoError For Each myerr In rdoErrors Debug.Print myerr.Number & " -- " & myerr.Description Next

End Sub 

