Microsoft KB Archive/149033

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

Article ID: 149033

Article Last Modified on 1/8/2003

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition

-



This article was previously published under Q149033



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:

129801 How to Create and Use a Minimal OLE Automation Server

Steps to Reproduce Behavior
  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  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.  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  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.

Keywords: kbbug KB149033

-

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

© Microsoft Corporation. All rights reserved.