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. Database & SysAdmin
  3. Database
  4. Unable to read binary field type

Unable to read binary field type

Scheduled Pinned Locked Moved Database
csharpc++databasedata-structureshelp
1 Posts 1 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.
  • B Offline
    B Offline
    BadKarma
    wrote on last edited by
    #1

    Hi, I've been googling all day, found info but it still doesn't work I have a binary field of 50 bytes long. I need to load this from the database and store it into a byte array in my application VC++ (NO .NET). But it seems I just can't convert the SafeArray data into a BYTE[]. I'm really stuck on this. I am getting despreratly, this shouldn't be this hard so what don't i see.

    ...
    _RecordsetPtr rsFoo;
    _variant_t vtHolder;
    int iMyID;
    BYTE* pMyData = new BYTE[50];
    try
    {
      rsFoo.CreateInstance(__uuidof(Recordset));
      rsFoo->Open((_bstr_t)strQuery, GetConnectionPtr().GetInterfacePtr(), adOpenDynamic,adLockReadOnly, adCmdText);
      
      if(rsFoo->adoEOF && rsFoo->BOF)
        return;
    
      vtHolder = rsFoo->GetCollect("ID");
      if(vtHolder.vt != NULL)
      {
        iMyId = (int)vtHolder;
      }
    
      vtHolder = rsFoo->GetCollect("Data");
      if(vtHolder.vt != NULL)
      {
        //
        // i come here, and getting in the watch window
        // safearray of UI1  = [50](0,0,0,0,0,0,0,0,0,0,0,...)	tagSAFEARRAY 
    
    ....
        // WHAT TO DO HERE TO PUT THIS INT pMyData 
    ....
      }
    }
    catch...
    

    codito ergo sum

    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