本帖最后由 xidiancjw 于 2010-05-12 13:15:25 编辑

解决方案 »

  1.   

    select id,name,age from stu where name=:name?
    查找成功就返回给你记录(游标)
    查找不成功,如果指正常的没有数据,那么返回给你的记录行数是0,也就是没有数据
    查找不成功,指错误,那么就会报对应的错误给你你大概没有写过类似的程序吧,不管什么语言都类似
      

  2.   

    直接select count(*) cnt from where 条件
    然后可判断cnt>0否
      

  3.   

    m_pRecordset.CreateInstance(__uuidof(Recordset));
    CString strSql;
    strSql.Format("select name from stu where stu.name='%s'",m_name);
      BSTR bstrSQL=strSql.AllocSysString();
    m_pRecordset->Open(bstrSQL,(IDispatch *)m_pConnection,adOpenStatic,adLockOptimistic,adCmdText);
      while(!m_pRecordset->adoEOF)
      {
          _variant_t var; 
          CString name;
         var = m_precordset->getcollect("name");
           if(var.vt != vt_null)
             name= _com_util::convertbstrtostring((_bstr_t)var); 
           m_precordset->movenext();
      }
    我是这样写的,不知道怎么进行判断,判断语句该怎么写啊?