BOOL CRecordset::IsOpen() const
// Note: assumes base class CRecordset::Close called
{
if (m_hstmt == NULL)
              return FALSE;
-----------//执行到这里显示错误!    Expression  Evaluator Error CXX0030
expression not evaluatable
         .........

}这是什么原因?

解决方案 »

  1.   

    注意这样几个问题即可:构造m_hstmt时初始化为null;创建m_hstmt实例没有?
      

  2.   

    你把程序给我发过来吧!我帮你看看!
    [email protected]
      

  3.   

    给你个例子:并推荐一本书《vc++数据库高级编程》---希望出版的
    /*****************************************************
    功能:初始化视图,并连接数据源及将记录集与数据源连接在一
          起.
    历史纪录:andy-21/5/2002
    ******************************************************/
    void CMyView::OnInitialUpdate()
    {
    CListView::OnInitialUpdate(); CListCtrl& ctrlList = (CListCtrl&) GetListCtrl();
    // Gain a reference to the list control itself
    ctrlList.SetExtendedStyle(LVS_EX_FULLROWSELECT); 
         
    m_pDatabase=new CDaoDatabase;//初始化数据源指针
    try//异常
    {
    m_pDatabase->Open("library.mdb");//打开数据源
    m_pRecordset=new CDaoRecordset(m_pDatabase);
    m_pRecordset1=new CDaoRecordset(m_pDatabase);
            //打开数据源相关的记录集
    }
    catch(CDaoException* e)
    {
    e->ReportError();
    delete m_pDatabase;
    m_pDatabase=NULL;
    e->Delete();
    return;
    }
    CString strKeyEntry;
    ///////////////////////////////////////////////////////
    //从注册表中读出
        strKeyEntry=_T("maxday");
    m_maxday=AfxGetApp()->GetProfileInt( RegisteKeys, strKeyEntry,21 );
    strKeyEntry=_T("maxbook");
    m_maxbook=AfxGetApp()->GetProfileInt( RegisteKeys,strKeyEntry,3 );
    strKeyEntry=_T("money");
    CString money;
    money=AfxGetApp()->GetProfileString( RegisteKeys, strKeyEntry,"0.2");
    char *temp=money.GetBuffer(money.GetLength()+1);
    m_money=atof(temp); ///////////////////////////////////////////////////////

    // TODO: You may populate your ListView with items by directly accessing
    //  its list control through a call to GetListCtrl().
    }
      

  4.   

    /**************************************************************
    响应"证卡管理"->"撤户办理(&X)"
    历史纪录:历史纪录:andy-24/5/2002
    ***************************************************************/
    void CMyView::OnCardRelease() 
    {
        m_strTableName=_T("用户信息");//设置当前操作的数据库表名称
       //监测dao数据库对象的有效性,并在纪录集对象打开时关闭该记录集
       if(!m_pDatabase->IsOpen())
       return;
       if(!m_pRecordset)
       return;
       if(m_pRecordset->IsOpen())
       m_pRecordset->Close();
        /////////////////////////////////////////////////////////
        CCarddeleteuser dlg;
    if(dlg.DoModal()!=IDOK)
    return;
    CString userid=dlg.m_userid;
    //AfxMessageBox(userid);
    CString strSql,str;
    //////////////////////////////////////////////////////////
    //判断是否是合法用户
        strSql.Format("select * from 用户信息");
    m_pRecordset->Open(dbOpenDynaset,strSql);
    str.Format("读者号='%s'",userid);
    if(!m_pRecordset->FindFirst(str))
    {
    str.Format("该用户未注册或输入错误,请确认输入!");
    AfxMessageBox(str);
    return;
    }
            m_pRecordset->Close();
    //判断是否借有书
    strSql.Format("select * from %s where  读者号='%s'",m_strTableName,userid);
        m_pRecordset->Open(dbOpenDynaset,strSql);
    str.Format("借阅书目个数>0");
    if(m_pRecordset->FindFirst(str))
    {
    AfxMessageBox("该用户还借有图书,不能注销!");
    return;
    }
    else
    {
     strSql.Format("delete from %s where 读者号='%s'",m_strTableName,userid);
    }
    try
    {
    if(m_pDatabase->CanUpdate())
       m_pDatabase->Execute(strSql);
    }
    catch(CDaoException *e)
    {
    e->ReportError();
    e->Delete();
    return;
    }
    OnZhbbUserall();}