我创建了一个VC6.0 MFC应用程序。我还将项目设置为unicode模式。
但是当我从sql db加载unicode数据(例如俄语)时,我也得到问号字符串“???? ...”
_variant_t TheValue;
CString str;
try
{
m_list.ResetContent();
//m_pConnection.CreateInstance(_uuidof(Connection));
m_pRecordset.CreateInstance(_uuidof(Recordset));
m_pRecordset->Open("SELECT * FROM MyUser",(IDispatch*)m_pConnection, adOpenDynamic, adLockOptimistic,adCmdText);
while(!m_pRecordset->adoEOF)
{
TheValue = m_pRecordset->GetCollect("name");
if(TheValue.vt!=VT_NULL)
{
str=(LPCSTR)_bstr_t(TheValue);
m_list.AddString(str);
}
m_pRecordset->MoveNext();
}
m_pRecordset->Close();
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format(L"Connect failedr\n error:%s", e.ErrorMessage());
AfxMessageBox(errormessage);
}