wanghai(汪海),你好,请问 %rowtype如何用,不好意思,小弟不会。多谢您指教!

解决方案 »

  1.   

    你指的是VC编程中使用的CRECORDSET还是数据库中的记录集
      

  2.   

    动态记录集为何不要游标类型呢?
    ......
    type mycursor is ref cursor;
    ......
    open mycurosr for 'select .......';
      

  3.   

    wanghai(汪海):我的原问题如下:
     boss叫我做一个报表生成程序,我用ODBC和ORACLE数据库连接,本来都做好了,可是到了公司一看,那儿的ORACLE数据库驱动不支持动态记录集,所以我把我的程序修改如下:
    CMySet* m_pDlgSet;(记录集指针)
    strSql = CString("select count(*) from els20.event ") +
     " where els20.event.eventtype like '火警%' " +
     " and els20.event.zeitbeginn between " +
     strDate_from[i] + " and LAST_DAY(" + strDate_from[i] + ")";
    m_pDlgSet->Open(CRecordset::forwardOnly,strSql,CRecordset::readOnly);
    这样就应该是不用动态记录集,而用只支持单向操作的只读记录集了,然后,我要获得count(*)的值,可是当我用下面的语句:
    m_pDlgSet->GetFieldValue((int)0,strResult);
    却报错:Invalide column number<1>
    当我在GetFieldValue上面加上:m_pDlgSet->MoveFirst();语句后,又出现错误:“记录集仅支持向前移动”;这样我想请问,该如何操作,才能取得我要的count(*)的值?
    因为boss催的急,还望各位大哥尽快不吝赐教!谢谢!
      

  4.   

    crecordset好象要先movenext到最后一行,记住不能直接用movelast,经过一个循环后再移到第一行,然后用GetRecordCount()来取记录数,msdn里有详细介绍
    Invalide column number<1>
    是因为列名错误了吧
      

  5.   

    wanghai(汪海):我刚才试了一下,
    open()后,
    //移到最后一条纪录
    while(!m_pDlgSet->IsEof())
    {
    m_pDlgSet->MoveNext(); 
    }
    m_pDlgSet->GetFieldValue((int)0,strResult);
    还是报错:非法的游标状态
      

  6.   

    还有,m_pDlgSet->GetFieldValue((int)0,strResult);这句应该没错,我原来做的程序中,先movefirst(),是可以的。还有,你说的“经过一个循环后再移到第一行”,如何实现,好像在这种记录集中只支持movenext()这种操作。
      

  7.   

    我这边没装VC,也没MSDN,你那边看看MSDN先
      

  8.   

    CRecordset::GetRecordCount
    long GetRecordCount( ) const;Return ValueThe number of records in the recordset; 0 if the recordset contains no records; or –1 if the record count cannot be determined.ResCall this member function to determine the size of the recordset. Caution   The record count is maintained as a “high water ” — the highest-numbered record yet seen as the user moves through the records. The total number of records is only known after the user has moved beyond the last record. For performance reasons, the count is not updated when you call MoveLast. To count the records yourself, call MoveNext repeatedly until IsEOF returns nonzero. Adding a record via CRecordset:AddNew and Update increases the count; deleting a record via CRecordset::Delete decreases the count. 
      

  9.   

    wanghai(汪海) :好像在我的程序中GetRecordCount并没有用,我要的是count(*)的值,而不是纪录条数,我试过了,GetRecordCount返回值就是1,是正确的,结果记录集应该就是1条,我看了MSDN,可惜没找到,你说open函数执行完以后,指向记录集的指针应该是指向哪一条纪录的?第一条还是最后一条?
      

  10.   

    我刚才试过了,open后记录集的指针应该是指向第一条纪录,那
    m_pDlgSet->GetFieldValue((int)0,strResult);这条语句就应该没错阿 ,
    为何还是出现Invalide column number<1>错误!我昏死!
      

  11.   

    wanghai(汪海):您知道如何修改ORACLE服务器吗?是之能够支持动态记录集