Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. varaint type conversion

varaint type conversion

Scheduled Pinned Locked Moved C / C++ / MFC
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John Smith
    wrote on last edited by
    #1

    In ADO you usually get all your values as Variants, Is there a easy way to convert any type into a string or BSTR

    C 2 Replies Last reply
    0
    • J John Smith

      In ADO you usually get all your values as Variants, Is there a easy way to convert any type into a string or BSTR

      C Offline
      C Offline
      Carlos Antollini
      wrote on last edited by
      #2

      Yes, var.bstrVal returns a BSTR type. Cheers!!!! Carlos Antollini.

      J 1 Reply Last reply
      0
      • J John Smith

        In ADO you usually get all your values as Variants, Is there a easy way to convert any type into a string or BSTR

        C Offline
        C Offline
        Carlos Antollini
        wrote on last edited by
        #3

        Look for this article in the MSDN: VARIANT and VARIANTARG Best Regards!!! Carlos Antollini.

        1 Reply Last reply
        0
        • C Carlos Antollini

          Yes, var.bstrVal returns a BSTR type. Cheers!!!! Carlos Antollini.

          J Offline
          J Offline
          John Smith
          wrote on last edited by
          #4

          No! I meant is there functionality that can convert any variant type e.g. int, long, double, currency to a BSTR. A microsoft Example has a CrackStrVariant function, but this does not cover all types.

          R 1 Reply Last reply
          0
          • J John Smith

            No! I meant is there functionality that can convert any variant type e.g. int, long, double, currency to a BSTR. A microsoft Example has a CrackStrVariant function, but this does not cover all types.

            R Offline
            R Offline
            Rashid Thadha
            wrote on last edited by
            #5

            I came across this problem recently, and found the perfect solution use _variant_t wrapper class e.g. converting a long to a BSTR

            _variant_t vLongVal((long)100);
            vLongVal.ChangeType(VTV_BSTR);

            // now you can use the bstr, that the ChangeTypr has converted
            _bstr_t vBstrValue(vLongVal.valbstr);

            This can be applied to any type I hope this helps :cool:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups