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

ID: Q149033


The information in this article applies to:
  • Microsoft Visual Basic Professional and Enterprise Editions, 16-bit only, for Windows, 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.


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:

Q129801 How to Create and Use a Minimal OLE Automation Server

Steps to Reproduce Behavior

  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.


Additional query words:

Keywords : kbVBp400
Version : 4.00 | 4.00
Platform : NT WINDOWS
Issue type :


Last Reviewed: September 17, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.