数据库里可以插入
list control为什么不行呀void CPage1::OnBnClickedButton1()
{CStuDataDlg stu1;
CString s1,s2,s3,s4,s5,s6,s7;
_RecordsetPtr m_pRecordset2;
_variant_t vid2,vname2,vmajor2,vclass2,vgrade2,vkb2,vic2;
if(UpdateData())
if(m_name.GetLength()>0)
{   m_pRecordset2.CreateInstance("ADODB.Recordset");
m_pRecordset2->Open("SELECT * FROM 学生总表",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
m_pRecordset2->AddNew();
 //  stu1.m_nCurrentSel =  stu1.m_ListCtrl.InsertItem(0xffff,"");
    stu1.vid= _variant_t(m_nid);
stu1.vname =_variant_t(m_name);
stu1.vmajor =_variant_t(m_major);
stu1.vclass = _variant_t(m_nclass);
stu1.vgrade = _variant_t(m_grade);
stu1.vkb =_variant_t(m_nkb);
        
m_pRecordset2->PutCollect("学号",stu1.vid);
m_pRecordset2->PutCollect("姓名",stu1.vname);
m_pRecordset2->PutCollect("专业",stu1.vmajor);
m_pRecordset2->PutCollect("班级",stu1.vclass);
m_pRecordset2->PutCollect("成绩",stu1.vgrade);
m_pRecordset2->PutCollect("课程编号",stu1.vkb);
m_pRecordset2->Update();
    vic2 = m_pRecordset2->GetCollect("索引");
    vid2 = m_pRecordset2->GetCollect("学号");
        vname2 = m_pRecordset2->GetCollect("姓名");
vmajor2 = m_pRecordset2->GetCollect("专业");
    vclass2 = m_pRecordset2->GetCollect("班级");
vgrade2 = m_pRecordset2->GetCollect("成绩");
    vkb2 = m_pRecordset2->GetCollect("课程编号");
s1=(LPCTSTR)_bstr_t(vic2);
        s2=(LPCTSTR)_bstr_t(vid2);
s3=(LPCTSTR)_bstr_t(vname2);
s4=(LPCTSTR)_bstr_t(vmajor2);
        s5=(LPCTSTR)_bstr_t(vclass2);
        s6=(LPCTSTR)_bstr_t(vgrade2);
        s7=(LPCTSTR)_bstr_t(vkb2);
    stu1.m_ListCtrl.InsertItem(31,s1);
        stu1.m_ListCtrl.SetItemText(31,1,s2);
stu1.m_ListCtrl.SetItemText(31,2,s3);
stu1.m_ListCtrl.SetItemText(31,3,s4);
stu1.m_ListCtrl.SetItemText(31,4,s5);
    stu1.m_ListCtrl.SetItemText(31,5,s6);
    stu1.m_ListCtrl.SetItemText(31,6,s7);
//stu1.SaveData();
///保存数据
 //   stu1.m_ListCtrl.SetItemState(stu1.m_nCurrentSel,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
//stu1.m_ListCtrl.SetHotItem(m_nCurrentSel);
// stu1.m_ListCtrl.SetFocus();
}
else
AfxMessageBox("请输入用户名");
}