Board index » cppbuilder » Help understanding Variant vs. TVariant

Help understanding Variant vs. TVariant

I am trying to use an ActiveX called MapX in a BCB5 SP1 program.  I am
on Windows ME.

I am using the techniques described in C++Builder 4 Unleashed.  I have
the following code:

   Variant param, ds;

   param = CreateOleObject("MapX.ODBCQueryInfo.3");

   param.OlePropertySet( "SqlQuery", "select * from USA" );
   param.OlePropertySet( "DataSource", "MapStatsV3" );
   param.OlePropertySet( "ConnectString", "ODBC" );

line 38>   ds = Map1->Datasets->Add( miDataSetODBC, param );

The compile fails with the messages:
[C++ Error] MainForm.cpp(38): E2015 Ambiguity between '_fastcall
Variant::operator TVariant()' and 'TVariant::TVariantT(const Variant &)'

[C++ Error] MainForm.cpp(38): E2342 Type mismatch in parameter
'SourceData' (wanted 'TVariant', got 'Variant')
[C++ Error] MainForm.cpp(38): E2015 Ambiguity between '_fastcall
System::Variant::operator =(const bool)' and '_fastcall
System::Variant::operator =(IUnknown *)'

If I change line 38 to:
ds = Map1->Datasets->Add( miDataSetODBC, (TVariant)param );
I don't get the second error but that can't be right to do.

I looked up the Add function in the cpp file generated when I imported
the Active X.  It looks like:

  Mapxlib_tlb::CMapXDatasetPtr __fastcall Add(short Type, TVariant
SourceData,
... (all other args are optional)

so you see it does want a TVariant.  But don't I need a Variant to be
able to use the OleProperty functions?

Any help will be appreciated.

Thanks in advance.

Hardee Mahoney
Washington, DC

 

Re:Help understanding Variant vs. TVariant


Did you include <utilcls.h> ?

Variant seems to want things from this header for your example to work.

"Hardee & Juan" <jsveg...@erols.com> wrote in message
news:3AAECB19.1DEBF40D@erols.com...

Quote
> I am trying to use an ActiveX called MapX in a BCB5 SP1 program.  I am
> on Windows ME.

> I am using the techniques described in C++Builder 4 Unleashed.  I have
> the following code:

>    Variant param, ds;

>    param = CreateOleObject("MapX.ODBCQueryInfo.3");

>    param.OlePropertySet( "SqlQuery", "select * from USA" );
>    param.OlePropertySet( "DataSource", "MapStatsV3" );
>    param.OlePropertySet( "ConnectString", "ODBC" );

> line 38>   ds = Map1->Datasets->Add( miDataSetODBC, param );

> The compile fails with the messages:
> [C++ Error] MainForm.cpp(38): E2015 Ambiguity between '_fastcall
> Variant::operator TVariant()' and 'TVariant::TVariantT(const Variant &)'

> [C++ Error] MainForm.cpp(38): E2342 Type mismatch in parameter
> 'SourceData' (wanted 'TVariant', got 'Variant')
> [C++ Error] MainForm.cpp(38): E2015 Ambiguity between '_fastcall
> System::Variant::operator =(const bool)' and '_fastcall
> System::Variant::operator =(IUnknown *)'

> If I change line 38 to:
> ds = Map1->Datasets->Add( miDataSetODBC, (TVariant)param );
> I don't get the second error but that can't be right to do.

> I looked up the Add function in the cpp file generated when I imported
> the Active X.  It looks like:

>   Mapxlib_tlb::CMapXDatasetPtr __fastcall Add(short Type, TVariant
> SourceData,
> ... (all other args are optional)

> so you see it does want a TVariant.  But don't I need a Variant to be
> able to use the OleProperty functions?

> Any help will be appreciated.

> Thanks in advance.

> Hardee Mahoney
> Washington, DC

Other Threads