Microsoft KB Archive/173659

= BUG: Custom Property from Provider of Type adIDispatch Fails =

Article ID: 173659

Article Last Modified on 3/1/2005

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.1 Service Pack 2

-



This article was previously published under Q173659



SYMPTOMS
ActiveX Data Objects (ADO) does not correctly recognize properties of type adIDispatch. If your ADO provider raises a custom property of type adIDispatch, ADO does not correctly return the interface, for example:

dim val as variant dim adoprop as adodb.property ...  set val = adoprop.Value

When the current property represented by adoprop is of type adIdispatch, ADO invokes the Interface's default method rather than the IDispatch interface, and attempts to return the result from that. If the interface's default method requires arguments, then the call fails and an error is returned. This error is dependent on the implementation of the interface, but typically it appears to be "Type Mismatch" from OLE objects implemented using MFC OLE.



RESOLUTION
There is no way to work around this bug within ADO. However, if you have created your own OLE-DB provider, you can get around this by raising the property, for example, as a column of a given recordset. In this case, you would bind the IDispatch to a column using the OLE-DB IAccessor::CreateAccessor interface, and then return that property via the IRowset:GetData method.

This workaround will work only if you have a custom OLE-DB provider and you have the source code for your OLE-DB provider.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior
Given a custom OLE-DB provider that raises a property to the ADO Recordset object of type adIdispatch, this code may generate unexpected results for that property:

Set adoprops = rs.Properties ' When Count is invoked, all properties are read from the provider. ' The IDIspatch interface incorrectly has it's default method invoked. for i = 0 To adoprops.Count - 1 set adoprop = adoprops.Item(i) 'For the custom property, the type is correctly returned as     ' 9 (DBTYPE_IDISPATCH) adotyp = adoprop.Type ' May generate an error as default method the interface is returned, ' rather than the actual interface set val = adoprop.Value Next i

Keywords: kbbug KB173659

-

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

© Microsoft Corporation. All rights reserved.