KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

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

Article: Q223068
Product(s): Microsoft Visual Basic for Windows
Version(s): WINDOWS:6.0
Operating System(s): 
Keyword(s): kbservicepack kbDatabase kbRDO kbVBp600bug kbVS600sp3fix kbGrpDSVBDB
Last Modified: 23-MAY-1999

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual Basic Enterprise Edition for Windows, version 6.0 
-------------------------------------------------------------------------------

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 this to be a bug in the Microsoft products 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:

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

Q194295 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.

1. 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.

2. Add a CommandButton to the default form.

3. Place the following code in the default form:

  Dim WithEvents rEngine As rdoEngine
  Dim cn As rdoConnection
  Const CONNECTSTR = "Driver={SQL Server};Server=(local);database=pubs;uid=sa;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

REFERENCES
==========

Visual Basic 6.0 Online Help

Additional query words:

======================================================================
Keywords          : kbservicepack kbDatabase kbRDO kbVBp600bug kbVS600sp3fix kbGrpDSVBDB 
Technology        : kbVBSearch kbAudDeveloper kbZNotKeyword6 kbZNotKeyword2 kbVB600Search kbVB600
Version           : WINDOWS:6.0
Issue type        : kbbug
Solution Type     : kbfix

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.