Board index » cppbuilder » How to pass array to ActiveX?

How to pass array to ActiveX?

I am trying to translate this VB-code to Cpp Builder but cant pass
the array with AddRows.
Am I all wrong?
Any help apriciatied /Mats

Dim cdoRowset As Object
Set cdoRowset = CreateObject("CrystalDataObject.CrystalComObject")

cdoRowset.AddField "Order ID", vbString
cdoRowset.AddField "Company Name", vbString
cdoRowset.AddField "Order Date", vbDate
cdoRowset.AddField "Order Amount", vbCurrency

Dim Rows(12, 4) As Variant
Rows(0, 0) = "1002"
Rows(0, 1) = "Cyclist's Trail Co."
Rows(0, 2) = #12/2/94#  
Rows(0, 3) = 5060.2725  

cdoRowset.AddRows Rows

//My C-code:
Variant cdoRowset;

cdoRowset = Variant::CreateObject(
"CrystalDataObject.CrystalComObject" );

cdoRowset.OleFunction( "AddField", "Resultat" );
cdoRowset.OleFunction( "AddField", "Analys" );

Variant rowsArray( OPENARRAY( int,(0,1,0,2 ) ), varOleStr );
rowsArray.PutElement( "Res1", 0, 0 );
rowsArray.PutElement( "S-ALAT", 0, 1 );

cdoRowset.OleFunction( "AddRows", rowsArray );   //When compiling
this row makes following error:
//[C++ Error] sysvari.h(1861): E2015 Ambiguity between
'TVariantT<tagVARIANT>::operator =(const TVariantT<tagVARIANT> &)'
and 'TVariantT<tagVARIANT>::operator =(bool)'.


Re:How to pass array to ActiveX?

Try putting the explicit cast to the Variant &.


Mats wrote:


Re:How to pass array to ActiveX?

Thanks for Your answer!

I changed the call to:
cdoRowset.Exec( Function( "AddRows" ) << rowsArray );
and i copiled but when running i get EOleException with message 'Type
missmatch in paramer. Must be an array object'

What is I doing wrong?

I added this to the code: nRet = VarType( rowsArray );
and nRet gets 8200 but varArray is defined as 8192

Any help greatly appreciated! / Mats

Other Threads