void CBnnnnDlg::OnButton1() 
{
// TODO: Add your control notification handler code here
CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset)); pConn->ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=学生.mdb;Persist Security Info=False";
pConn->Open("","","",adConnectUnspecified); pRst=pConn->Execute("select * from 会员列表",NULL,adCmdText); while (!pRst->adoEOF)
{
((CListBox*)GetDlgItem(IDC_LIST1))->ADDString((_bstr_t)pRst->GetCollect("姓名"));
pRst->MoveNext();

}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();}
以上是看孙新老师的视频写的代码,看视频可以编译成功,但是我在本机上编译就不成功!提示
'ADDString' : is not a member of 'CListBox'
我实在是搞不明白了~~请高手指教!
我找了MSDN,CListBox类里确实没有ADDString这个成员函数啊~,那为什么视频上就能编译成功?

解决方案 »

  1.   

    CComboBox才有AddString函数另外你的ADDString函数也写错了,应该是AddString
      

  2.   

    啊~谢谢!!我改成AddString终于编译通过了!
    我还有一个问题啊!就是为什么我调试运行的时候弹出一个错误框
    Runtime Error!Program:d:\text\bnnnn\Debug\bnnnn.exeThis application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information.确定
    一点确定就直接退出了但是我直接在DEBUG文件夹里运行刚刚生成的那个BNNNN.EXE却运行正常,也能访问数据库?