void CMyView::OnAdd() 
{
    CDialog dlg;
if( dlg.DoModal()==IDOK)
  {  
if(dlg.m_name==0)
{
 AfxMessageBox("姓名不可为空!");
}
else
{
 m_pSet->AddNew();
          m_pSet->m_column1=dlg.m_name;
                   m_pSet->m_column2=dlg.m_phone_cell;
          m_pSet->m_column3=dlg.m_phone_home;
 m_pSet->m_column4=dlg.m_phone_work;
 m_pSet->m_column5=dlg.m_company;
 m_pSet->m_column6=dlg.m_email;
                  m_pSet->Update();
          m_pSet->Requery();
          m_pSet->MoveLast();
CString s;
//s.Format("%d",dlg.m_name);
m_ListCtrl.InsertItem(0,dlg.m_name,1);
m_ListCtrl.SetItemText(0,2,dlg.m_phone_cell);
m_ListCtrl.SetItemText(0,3,dlg.m_phone_home);
m_ListCtrl.SetItemText(0,4,dlg.m_phone_work);
m_ListCtrl.SetItemText(0,5,dlg.m_company);
m_ListCtrl.SetItemText(0,6,dlg.m_email);
}   }
        m_pSet->MoveFirst();
}运行程序,弹出提示框: 
            Debug Assertion Failed!            Program:C:\vc\vc.exe
            File:afx.inl
            Line:157            ...请问这是怎么回事,该如何解决,谢先!!

解决方案 »

  1.   

    m_pSet->AddNew();处设置断点
    用F5单步执行
      

  2.   

    你的程序问题比较多:
    (1) 没有确定数据集是否是打开的,if(!m_pSet->Open())--->m_pSet->AddNew(),就出问题了;
    (2) 程结束后应m_pSet->Close();
    (3) 在程序中应该完全使用异常处理,如:
            try
            {
                 m_pSet->AddNew();
            }
            cacth(CDBException* e)
            {
                 AfxMessageBox("Do not add new record!");
                 AfxMessageBox(e->m_strError);
            }
        这样你就很容易知道程序运行的问题所在了.