Why do I receive "Warning: ActiveX - unsupported VARIANT type encountered" when using the MATLAB COM Client Interface on 64-bit Windows?

2 views (last 30 days)
I am using the 64-bit version of MATLAB 7.6 (R2008a) on a 64-bit Windows machine, and I am creating a COM object in the MATLAB workspace:
obj = actxserver('ADODB.Connection');
I then invoke one of its methods:
sql = 'SELECT * FROM MYTABLE';
rset = invoke(obj, 'execute', sql);
The returned object has a numeric property I wish to access. However, when attempting to access the property, I get a warning, and a value of NaN is substituted for the expected number:
>> rset.RecordCount
Warning: ActiveX - unsupported VARIANT type encountered
ans =
NaN
Running 32-bit MATLAB on 32-bit Windows, I do not receive this warning:
>> rset.RecordCount
ans =
2
I can also see that on the 32-bit machine, the class of the returned number is 32-bit integer:
 
>> class(rset.RecordCount)
ans =
int32

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 1 Feb 2017
This enhancement has been incorporated in Release 2010b (R2010b). For previous product releases, read below for any possible workarounds:
This change has been incorporated into the documentation in Release 2009a (R2009a). For previous releases, read below for any additional information:
It is most likely that the data type of the property being accessed is 64-bit integer (int64), which is equivalent to the OLE type VT_I8 (it may also be a 64-bit unsigned integer, equivalent to VT_UI8). This is a data type that is not supported by the MATLAB COM Client Interface. This is stated in the following page in the official documentation:
You can verify whether the property of the object being returned is of an unsupported type by viewing the type library of the ActiveX server and locating the definition for the property. One way to do this is by using the OLEView tool and opening the server DLL file:
In the case of the example, we see from the type library of the Microsoft ActiveX Data Objects 2.8 Library that the 'RecordCount' property is ultimately defined as int64:
 
HRESULT RecordCount([out, retval] ADO_LONGPTR* pl);
...
typedef [uuid(54D8B4B9-663B-4A9C-95F6-0E749ABD70F1), public]
int64 ADO_LONGPTR;

More Answers (0)

Products


Release

R2008a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!