943,708 Members | Top Members by Rank

Ad:
  • Oracle Discussion Thread
  • Unsolved
  • Views: 1317
  • Oracle RSS
Nov 2nd, 2008
0

Writing Unicode to Oracle

Expand Post »
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.

Oracle Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dcoorey is offline Offline
1 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC