VC++ 6 atl/com Accessors ole db, % char in db field


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: VC++ 6 atl/com Accessors ole db, % char in db field

  1. #1
    Join Date
    Nov 2005
    Posts
    2

    VC++ 6 atl/com Accessors ole db, % char in db field

    Hi all,

    I lost a painful day as developers may sometime lose, bad this time I didnít find myself the solution;

    I used the ATL Object Wizard Ė Data Access Ė Consumer, etc..

    Letís say my code is something link that:

    class CUserSimpleAccessor:public CUser{
    BEGIN_COLUMN_MAP(CUserSimpleAccessor)
    COLUMN_ENTRY(1, m_USERID)
    COLUMN_ENTRY(2, m_USERINFO)
    END_COLUMN_MAP()

    void ClearRecord(){
    memset(this, 0, sizeof(*this));
    }
    };

    class CUserIDAccessor:public CUserSimpleAccessor{

    BEGIN_PARAM_MAP(CUserCatUserIDAccessor)
    COLUMN_ENTRY(1, m_USERID)
    END_PARAM_MAP()

    DEFINE_COMMAND(CUserCatUserIDAccessor, _T("SELECT USER_ID, USER_INFO FROM test_schema.User where USER_ID=?"))
    };

    If the user_info field in Oracle as 10 characters but this field contains for example2 Ď%í characters, then strlen(m_USERINFO) returns 8 ! I lost the 2 characters in my chain.
    I suppose it must be in the macros that somewhere do a copy and the Ď%í is assumed to be a special character but since I do not have to knowledge to modify the atldbcli.h, etc... in order to trace the problem.

    I canít change the values in the Oracle table, those are used also by other applications, so I have to cope with this character as it is now (I need them, I miss them, sniff)

    Is there a tip, trick or something easy ?

    Thank you in advance
    Fred

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    I don't know much about Oracle's secret handshake, i.e., which secret component deals with special characters such as %c but this line of code worries me:
    memset(this, 0, sizeof(*this));

    Never zero initialize an object that has virtual functions in this way. You're destroying internal data members that are needed for resolving virtual function calls, resulting undefined behavior.
    As for the mysterious string: before calling strlen, check what the string contains. Is the % still there?
    Danny Kalev

  3. #3
    Join Date
    Dec 2003
    Posts
    3,366
    I sort of make it a rule of thumb not to memset anything except C arrays and C structs (no functions, just data). I try to avoid the structs as well when I can.

  4. #4
    Join Date
    Nov 2005
    Posts
    2
    I would like to thank you for your replies but I found my problem, it what of course a newbie error, somewhere in my code I made sprintf instead of a strcpy in order to copy a TCHAR* to an other TCHAR*

    Sorry
    Fred

Similar Threads

  1. Runtime error w/ Variable Type Part II
    By jamestmfbong in forum C++
    Replies: 2
    Last Post: 05-04-2009, 07:03 PM
  2. Replies: 9
    Last Post: 07-28-2005, 09:40 PM
  3. Replies: 0
    Last Post: 02-26-2001, 10:57 PM
  4. Ted, you're a prince!
    By Georgiana Trigg in forum VB Classic
    Replies: 0
    Last Post: 10-29-2000, 12:21 PM
  5. VB/C Array parameters
    By Gastao Woelfert in forum VB Classic
    Replies: 2
    Last Post: 09-01-2000, 12:36 PM

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