Writing Unicode to Oracle

Reply

Join Date: Nov 2008
Posts: 1
Reputation: dcoorey is an unknown quantity at this point 
Solved Threads: 0
dcoorey's Avatar
dcoorey dcoorey is offline Offline
Newbie Poster

Writing Unicode to Oracle

 
0
  #1
Nov 2nd, 2008
Hi All,

I am having problems trying to write unicode characters to a version 10 Oracle database, using C++ and OLE DB (the same code works with MS SQL). If I insert a unicode string directly from PL SQL it works, otherwise I get nonsense when trying from my code. I have set ORA_NCHAR_LITERAL_REPLACE to true in the registry on the Oracle server, which I believe is a requirement. I would really appreciate any suggestions or help here. The code I am using is as follows.

  1. void CAGROracleTestHarness::CONNECT()
  2. {
  3. CoInitialize(NULL);
  4.  
  5. m_dsDBSource = NEW CDataSource();
  6. m_csConnection = NEW CSession();
  7. m_pcmdStatement = NEW CCommand<CDynamicAccessor>;
  8.  
  9. CDBPropSet ConnectionProperties(DBPROPSET_DBINIT);
  10.  
  11. ConnectionProperties.AddProperty(DBPROP_INIT_DATASOURCE, m_sServer);
  12.  
  13. ConnectionProperties.AddProperty(DBPROP_AUTH_USERID, m_sUserID);
  14.  
  15. ConnectionProperties.AddProperty(DBPROP_AUTH_PASSWORD, m_sPassword);
  16.  
  17. ConnectionProperties.AddProperty(DBPROP_INIT_CATALOG, m_sDatabase);
  18.  
  19. ConnectionProperties.AddProperty(DBPROP_INIT_PROMPT, (short)DBPROMPT_NOPROMPT);
  20.  
  21. m_dsDBSource->OpenWithServiceComponents(m_sProvider, &ConnectionProperties));
  22.  
  23. // OPEN the connection.
  24. m_csConnection->Open(*m_dsDBSource);
  25. }
  26.  
  27. void CAGROracleTestHarness::EXECUTE()
  28. {
  29. CONNECT();
  30.  
  31. CDBPropSet ConnectionProperties(ORAPROPSET_COMMANDS);
  32. ConnectionProperties.AddProperty(ORAPROP_NDatatype, TRUE);
  33.  
  34. HRESULT hResult = m_pcmdStatement->Open(*m_csConnection, _T("UPDATE client SET
  35. comments = N'文本的' WHERE id = 2"), &ConnectionProperties);
  36. }

Thanks in advance.

David Coorey.
Last edited by peter_budo; Nov 3rd, 2008 at 2:36 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC