可恨现在手头上没有msdn!

解决方案 »

  1.   

    用SQL语句不就可以实现了吗?
      

  2.   

    CRecordset Class Members
    Data Members
    Construction
    Recordset Attributes
    Recordset Update Operations
    Recordset Navigation Operations
    Other Recordset Operations
    Recordset OverridablesData Members m_hstmt Contains the ODBC statement handle for the recordset. Type HSTMT. 
    m_nFields Contains the number of field data members in the recordset. Type UINT. 
    m_nParams Contains the number of parameter data members in the recordset. Type UINT. 
    m_pDatabase Contains a pointer to the CDatabase object through which the recordset is connected to a data source. 
    m_strFilter Contains a CString that specifies a Structured Query Language (SQL) WHERE clause. Used as a filter to select only those records that meet certain criteria. 
    m_strSort Contains a CString that specifies an SQL ORDER BY clause. Used to control how the records are sorted. 
    Construction CRecordset Constructs a CRecordset object. Your derived class must provide a constructor that calls this one. 
    Open Opens the recordset by retrieving the table or performing the query that the recordset represents. 
    Close Closes the recordset and the ODBC HSTMT associated with it. 
    Recordset Attributes CanAppend Returns nonzero if new records can be added to the recordset via the AddNew member function. 
    CanBook Returns nonzero if the recordset supports books. 
    CanRestart Returns nonzero if Requery can be called to run the recordset’s query again. 
    CanScroll Returns nonzero if you can scroll through the records. 
    CanTransact Returns nonzero if the data source supports transactions. 
    CanUpdate Returns nonzero if the recordset can be updated (you can add, update, or delete records). 
    GetODBCFieldCount Returns the number of fields in the recordset. 
    GetRecordCount Returns the number of records in the recordset. 
    GetStatus Gets the status of the recordset: the index of the current record and whether a final count of the records has been obtained. 
    GetTableName Gets the name of the table on which the recordset is based. 
    GetSQL Gets the SQL string used to select records for the recordset. 
    IsOpen Returns nonzero if Open has been called previously. 
    IsBOF Returns nonzero if the recordset has been positioned before the first record. There is no current record. 
    IsEOF Returns nonzero if the recordset has been positioned after the last record. There is no current record. 
    IsDeleted Returns nonzero if the recordset is positioned on a deleted record. 
    Recordset Update Operations AddNew Prepares for adding a new record. Call Update to complete the addition. 
    CancelUpdate Cancels any pending updates due to an AddNew or Edit operation. 
    Delete Deletes the current record from the recordset. You must explicitly scroll to another record after the deletion. 
    Edit Prepares for changes to the current record. Call Update to complete the edit. 
    Update Completes an AddNew or Edit operation by saving the new or edited data on the data source. 
    Recordset Navigation Operations GetBook Assigns the book value of a record to the parameter object. 
    Move Positions the recordset to a specified number of records from the current record in either direction. 
    MoveFirst Positions the current record on the first record in the recordset. Test for IsBOF first. 
    MoveLast Positions the current record on the last record or on the last rowset. Test for IsEOF first. 
    MoveNext Positions the current record on the next record or on the next rowset. Test for IsEOF first. 
    MovePrev Positions the current record on the previous record or on the previous rowset. Test for IsBOF first. 
    SetAbsolutePosition Positions the recordset on the record corresponding to the specified record number. 
    SetBook Positions the recordset on the record specified by the book. 
    Other Recordset Operations Cancel Cancels an asynchronous operation or a process from a second thread. 
    FlushResultSet Returns nonzero if there is another result set to be retrieved, when using a predefined query. 
    GetFieldValue Returns the value of a field in a recordset. 
    GetODBCFieldInfo Returns specific kinds of information about the fields in a recordset. 
    GetRowsetSize Returns the number of records you wish to retrieve during a single fetch. 
    GetRowsFetched Returns the actual number of rows retrieved during a fetch. 
    GetRowStatus Returns the status of the row after a fetch. 
    IsFieldDirty Returns nonzero if the specified field in the current record has been changed. 
    IsFieldNull Returns nonzero if the specified field in the current record is Null (has no value). 
    IsFieldNullable Returns nonzero if the specified field in the current record can be set to Null (having no value). 
    RefreshRowset Refreshes the data and status of the specified row(s). 
    Requery Runs the recordset’s query again to refresh the selected records. 
    SetFieldDirty Marks the specified field in the current record as changed. 
    SetFieldNull Sets the value of the specified field in the current record to Null (having no value). 
    SetLockingMode Sets the locking mode to “optimistic” locking (the default) or “pessimistic” locking. Determines how records are locked for updates. 
    SetParamNull Sets the specified parameter to Null (having no value). 
    SetRowsetCursorPosition Positions the cursor on the specified row within the rowset. 
    Recordset Overridables Check Called to examine the return code from an ODBC API function. 
    CheckRowsetError Called to handle errors generated during record fetching. 
    DoBulkFieldExchange Called to exchange bulk rows of data from the data source to the recordset. Implements bulk record field exchange (Bulk RFX). 
    DoFieldExchange Called to exchange data (in both directions) between the field data members of the recordset and the corresponding record on the data source. Implements record field exchange (RFX). 
    GetDefaultConnect Called to get the default connect string. 
    GetDefaultSQL Called to get the default SQL string to execute. 
    OnSetOptions Called to set options for the specified ODBC statement. 
    SetRowsetSize Specifies the number of records you wish to retrieve during a fetch. 
      

  3.   

    没有你要得,用SQL语句就行了。
      

  4.   

    To zhouyong0371(小周周):执行SQL语句后如何返回结果呢,我一直没解决这个问题,所以只好用笨办法。我是先排序,Order by FiledName。然后取第一个的值就是最小值,最后一个的值是最大值。不过这方法太笨了。
      

  5.   

    rs->Open(AFX_DB_USE_DEFAULT_TYPE,(LPCTSTR)"SELECT MAX(ID) AS maxinum, MIN(ID) AS mininum FROM TabStru",0);
    CString sMax,sMin;
    rs->GetFieldValue(0,sMax);
    rs->GetFieldValue(1,sMin);
      

  6.   

    那不是每查找一次就要先close一次然后打开一次,不爽啊.
    执行sql语句的,不是有一个函数的吗?
      

  7.   

    现在我知道怎么做了
    原来我是用CRecordSet的派生类的,这样,就不用处理CDataBase(尽管实际上有,但是不用处理),派生的时候就会选择数据源和表的。
    现在我用CDataBase,需要的时候再定义CRecordSet类,就可以加进sql语句了。
    不过现在想起来,我原来的做法也是可以的,但是对于同一个对象,进行不同的处理时要不断的open、close。而后一种做法,就可以做到一个对象,一种处理。
    二者实质一样的。
    谢谢各位了。
      

  8.   

    to jnxulei(石头) 
    执行sql语句后,如果返回的是一系列的记录集的话,就返回首指针,你MoveFirst后一路MoveNext就可以了,如果返回的是一些值,例如max,就保存在你定义的变量里,用gxingmin(小高) 的办法就可以了。