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.
Last edited by peter_budo; Nov 3rd, 2008 at 2:36 am. Reason: Keep It Organized - please use [code] tags