Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ VC 6.0 MFC如何将unicode数据从sql server读入CListBox_C++_Unicode_Mfc_Bstr - Fatal编程技术网

C++ VC 6.0 MFC如何将unicode数据从sql server读入CListBox

C++ VC 6.0 MFC如何将unicode数据从sql server读入CListBox,c++,unicode,mfc,bstr,C++,Unicode,Mfc,Bstr,我已经创建了一个VC6.0 MFC应用程序。我还将项目设置为unicode模式。 但是当我从sql db加载unicode数据(例如俄语)时,我也会得到问号字符串“?” 将BSTR强制转换为char*。这是不允许的。m_列表是什么类型的?它不是一个支持unicode的数据类Maybe may help.xMRi,m_列表的类型为CListBoxstr=(LPCSTR)\u bstr\u t(值)应该是str=(LPCSTRT)\u bstr\u t(值)-注意T _variant_t TheV

我已经创建了一个VC6.0 MFC应用程序。我还将项目设置为unicode模式。

但是当我从sql db加载unicode数据(例如俄语)时,我也会得到问号字符串“?”


将BSTR强制转换为char*。这是不允许的。m_列表是什么类型的?它不是一个支持unicode的数据类Maybe may help.xMRi,m_列表的类型为CListBox
str=(LPCSTR)\u bstr\u t(值)应该是
str=(LPCSTRT)\u bstr\u t(值)-注意T
_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 failedr\n error:%s", e.ErrorMessage());
    AfxMessageBox(errormessage);
}