BUG: Pass Database Object to 16-Bit OLE Server Causes 80010104

Last reviewed: April 11, 1996
Article ID: Q149033
The information in this article applies to:
  • Professional and Enterprise Editions of Microsoft Visual Basic for Windows, 16-bit only, version 4.0

SYMPTOMS

Attempting to pass a DAO Database object to a 16-bit OLE server created with Visual Basic 4.0 16-bit can cause error -2147417852 (80010104) with early-binding, or run-time error 13 - Type Mismatch when using late- binding. This error is caused when the parameter list in the OLE server for the function or subroutine has an element declared As Database.

STATUS

Microsoft has confirmed this to be an issue in the Microsoft products listed at the beginning of this article. Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

WORKAROUND

Declare the element of the parameter list As Object instead of As Database. For example, instead of using

   Public Sub PassDB(MyDB As Database)

use:

   Public Sub PassDB(MyDB As Object)

All code in the body of the procedure or function that takes the database object can be written in the same way as if the parameter had been passed As database. Note that the As Database will work correctly with Visual Basic 4.0 32-bit and Jet 3.0.

MORE INFORMATION

For additional information, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q129801
   TITLE     : How to Create and Use a Minimal OLE Automation Server


Steps to Reproduce

  1. Create a minimal OLE server and a client that accesses the OLE server. (Step-by-step instructions for this procedure are found in the article [Q129801] referenced above and assume a client and server created from this article. However, they can be implemented in any client and server to see the behavior described in this article.) Add this code to the class module in the OLE server project:

    Public Sub PassDB(MyDB as Database)

       End Sub
    
    

  2. On the Run menu, choose Start or press F5 to run the server application. In the client application, add a reference to the running OLE server.

  3. Modify the Form_Click event of Form1 in the client project to contain the following code:

    Public Sub Form_Click()

          Dim x As Project1.Class1
          Dim db As Database
          Set x = New Project1.Class1
          Set db = OpenDatabase("Biblio.mdb")
          x.PassDB db
    
       End Sub
    
    

  4. On the Run menu, choose Start or press F5 to run the client application. Click on the form. The client program will raise the error mentioned above on the line calling the PassDB method of the OLE server. If the server is stopped and the type of MyDB is changed from Database to Object, the client code will work correctly.


KBCategory: kbprg kbbuglist
KBSubcategory: APrgData IAPOLE
Additional reference words: 4.00 vb4win vb4all



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.

Last reviewed: April 11, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.