DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Need help with using ADO and C++

  1. #1
    James Guest

    Need help with using ADO and C++


    Could someone please direct me to information on how to convert the variant
    type data elements I am pulling from an Access 2000 database with ADO into
    standard C++ datatypes (i.e. int, char, cstring) that I can use in my program.
    I can connect to the data source and pull the data into the variant type
    just fine.... just don't know how to convert the data type. Thank you!


  2. #2
    Jack Guest

    Re: Need help with using ADO and C++


    You have a few choices... You can use the following datatypes:

    VARIANT
    _variant_t
    CComVariant

    for _variant_t types, you can determine what type it's holding by evaluating
    the "vt" data member. Here's how you can get a long from the variant:

    _variant_t var;

    var = pRecSet->Fields->GetItem( SOME_FIELD )->Value;

    if( var.vt == VT_I4 )
    myLong = var;

    _variant_t overloads the type operators to give you ways to extract datatypes
    easily. See MSDN for more information on _variant_t

    "James" <S1cavenger@aol.com> wrote:
    >
    >Could someone please direct me to information on how to convert the variant
    >type data elements I am pulling from an Access 2000 database with ADO into
    >standard C++ datatypes (i.e. int, char, cstring) that I can use in my program.
    >I can connect to the data source and pull the data into the variant type
    >just fine.... just don't know how to convert the data type. Thank you!
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center