CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004
    Location
    Israel
    Posts
    174

    reading database with ADOB

    i tried this code to read from access DB
    and when i access a cell that is empty and not null with this code :
    PHP Code:
    name =_strdup((char*) ((_bstr_t)(pConnectRead->GetFields()->GetItem("name")->GetValue())) ); 
    then i get an error : type mismatch
    why is that?
    thnaks in advance
    peleg

  2. #2
    Join Date
    Dec 2000
    Location
    Dallas, Texas
    Posts
    62

    Post Re: reading database with ADOB

    Quote Originally Posted by pelegk2
    i tried this code to read from access DB
    and when i access a cell that is empty and not null with this code :
    PHP Code:
    name =_strdup((char*) ((_bstr_t)(pConnectRead->GetFields()->GetItem("name")->GetValue())) ); 
    then i get an error : type mismatch
    why is that?
    thnaks in advance
    peleg
    Try this:

    COleVariant Var;
    Var = recordset->Fields->GetItem("FirstName")->Value;
    firstName = ( Var.vt == VT_NULL ? _T("") : ((char *) (_bstr_t)Var.bstrVal) );

    This above code definitely works.

    Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured