dcoorey 0 Newbie Poster

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.

void CAGROracleTestHarness::Connect()
{
 CoInitialize(NULL);

 m_dsDBSource = new CDataSource();
 m_csConnection = new CSession();
 m_pcmdStatement = new CCommand<CDynamicAccessor>;

 CDBPropSet ConnectionProperties(DBPROPSET_DBINIT);

 ConnectionProperties.AddProperty(DBPROP_INIT_DATASOURCE, m_sServer);

 ConnectionProperties.AddProperty(DBPROP_AUTH_USERID, m_sUserID);

 ConnectionProperties.AddProperty(DBPROP_AUTH_PASSWORD, m_sPassword);

 ConnectionProperties.AddProperty(DBPROP_INIT_CATALOG, m_sDatabase);

 ConnectionProperties.AddProperty(DBPROP_INIT_PROMPT, (short)DBPROMPT_NOPROMPT);

 m_dsDBSource->OpenWithServiceComponents(m_sProvider, &ConnectionProperties));

 // Open the connection.
 m_csConnection->Open(*m_dsDBSource);
}

void CAGROracleTestHarness::Execute()
{
 Connect();

 CDBPropSet ConnectionProperties(ORAPROPSET_COMMANDS);
 ConnectionProperties.AddProperty(ORAPROP_NDatatype, true);

 HRESULT hResult = m_pcmdStatement->Open(*m_csConnection, _T("UPDATE client SET  
                                      comments = N'文本的' WHERE id = 2"), &ConnectionProperties);
}

Thanks in advance.

David Coorey.