小弟在调一个VC++技术内幕(第四版)的ex28a程序时,没有什么语法错误,但却弹出一个窗口,信息如下:
    Debug Assertion Failed!
    Program:D:\ex28a\Debug\ex28a.exe
    File:afxdb.inl
    Line:48
    For information on how your program can cause an assertion failure,see the Visual C++ documentation on asserts.
    (press Retry to debug the application)
还有三个按钮,分别为:
  终止(A)    重试(R)    忽略(I)
 
当我按了重试按钮时,又弹出一个窗口,信息如下:
应用程序发生异常 unknown software exception(0x80000003),位置为0x5f70b341。
要终止程序,请单击“确定”。
要调试程序,请单击“取消”。
 还有“确定”按钮和“取消”按钮请问这是怎么回事啊?是什么错误啊,但却没语法错误,也没逻辑错误啊,因为我是照着书上的例题抄的啊??????帮帮忙啊!

解决方案 »

  1.   

    凡是出现ASSERT失败的时候一般都是指针的问题!
      

  2.   


    void CEx28aView::OnDraw(CDC* pDC)
    {
        TEXTMETRIC tm;
        pDC->GetTextMetrics(&tm);
    int nLineHeight=tm.tmHeight+tm.tmExternalLeading;
    CPoint pText(0,0);

    int y=0;
    CString str;
    if(m_pSet->IsBOF()){
    return;
    }
    m_pSet->MoveFirst();
    while(!m_pSet->IsEOF()){
    str.Format("%ld", m_pSet->m_StudentID);
    pDC->TextOut(pText.x,pText.y,str);
    pDC->TextOut(pText.x+1000,pText.y,m_pSet->m_Name);
    str.Format("%d",m_pSet->m_GradYear);
    pDC->TextOut(pText.x+4000,pText.y,str);
    m_pSet->MoveNext();
    pText.y-=nLineHeight;    } 
    }void CEx28aView::OnInitialUpdate()
    {

    CScrollView::OnInitialUpdate(); CSize sizeTotal(8000,10500);
    // TODO: calculate the total size of this view
    sizeTotal.cx = sizeTotal.cy = 100;
    SetScrollSizes(MM_HIENGLISH, sizeTotal);
    m_pSet=&GetDocument()->m_ex28aSet;
    if(m_pSet->IsBOF()){
    m_pSet->Close();
    }
    m_pSet->Open(); 
    }
     这是加上去的源程序
      

  3.   

    你做了书上说的这一步没?
    1.运行ODBC数据源管理程序来安装学生注册数据源
      

  4.   

    我试过了的,不过用的另外的一个mdb数据库文件,好没出问题.....