Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    397

    Database -> Treeview issues in unicode

    Wohoo Im back with another irritating mindblowingly complex question, joke

    Code:
    			CString szLabel;
    
    			while(SQLFetch(cData->sqlstatementhandle)==SQL_SUCCESS){
    						
    				SQLGetData(cData->sqlstatementhandle, 1, SQL_C_CHAR, &szLabel, 50, NULL);
    				m_OrgTree.InsertItem(szLabel, NULL, NULL, hPA, 0);
    				
    			}
    This crashed on me so many times, ive even tried regular String and WString with the .c_str, ive tried countless forms, I can get it working in Ansi but unicode, OMG anyone any Idea's on why it wont store data etc.

    Im not tied to CString, if anyone can think of another variable type that will happily end up as an "LPCTSTR" Ill gladly take it?

    I can do m_OrgTree.InsertItem(_T("Whatever"), NULL, NULL, hPA, 0); and have no issues so its the variable

  2. #2
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    Quote Originally Posted by sarriss2 View Post
    Code:
    			while(SQLFetch(cData->sqlstatementhandle)==SQL_SUCCESS){
    						
    				SQLGetData(cData->sqlstatementhandle, 1, SQL_C_CHAR, &szLabel, 50, NULL);
    				m_OrgTree.InsertItem(szLabel, NULL, NULL, hPA, 0);
    				
    			}
    This crashed on me so many times, ive even tried regular String and WString with the .c_str, ive tried countless forms, I can get it working in Ansi but unicode, OMG anyone any Idea's on why it wont store data etc.
    what kind of crash? what exactly does not work? and what database are you actually using there?

    Im not tied to CString, if anyone can think of another variable type that will happily end up as an "LPCTSTR" Ill gladly take it?
    ::std::basic_string<TCHAR>. this is the template that ::std::string is based upon, instantiated for whatever char type windows likes at the moment. should work fine on all occasions

  3. #3
    Join Date
    Nov 2008
    Posts
    397
    well solved this one, but mostly by fluke, im not a unicode person

    Code:
    			HTREEITEM hPA = m_OrgTree.InsertItem(_T("Tables"), NULL, NULL);			
    
    			WCHAR g_szClass[50] = _T("");
    
    
    			TVINSERTSTRUCT tvInsert;
    			tvInsert.hParent = hPA;
    			tvInsert.hInsertAfter = NULL;
    			tvInsert.item.mask = TVIF_TEXT;
    
    
    			while(SQLFetch(cData->sqlstatementhandle)==SQL_SUCCESS){
    	
    				SQLGetData(cData->sqlstatementhandle, 1, SQL_C_WCHAR, &g_szClass, 50, NULL);
    				
    				tvInsert.item.pszText = g_szClass;
    
    				m_OrgTree.InsertItem(&tvInsert);
    							
    			}

Posting Permissions

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