--- description: "Learn more about: CRowset Class" title: "CRowset Class" ms.date: "11/04/2016" f1_keywords: ["ATL.CRowset", "CRowset", "ATL::CRowset", "ATL::CRowset", "ATL.CRowset", "CRowset.AddRefRows", "CRowset.AddRefRows", "ATL.CRowset.AddRefRows", "AddRefRows", "CRowset::AddRefRows", "CRowset::AddRefRows", "ATL::CRowset::AddRefRows", "ATL.CRowset.AddRefRows", "ATL::CRowset::AddRefRows", "CRowset::Close", "ATL.CRowset.Close", "CRowset::Close", "CRowset.Close", "ATL.CRowset.Close", "ATL::CRowset::Close", "ATL::CRowset::Close", "CRowset.Close", "CRowset.Compare", "CRowset::Compare", "ATL.CRowset.Compare", "ATL::CRowset::Compare", "CRowset.Compare", "ATL::CRowset::Compare", "ATL.CRowset.Compare", "CRowset::Compare", "CRowset::CRowset", "CRowset.CRowset", "ATL::CRowset::CRowset", "ATL::CRowset::CRowset", "ATL.CRowset.CRowset", "CRowset.CRowset", "CRowset::CRowset", "ATL.CRowset.CRowset", "ATL::CRowset::Delete", "CRowset.Delete", "CRowset::Delete", "ATL.CRowset.Delete", "ATL::CRowset::Delete", "CRowset.Delete", "CRowset::Delete", "ATL.CRowset.Delete", "ATL.CRowset.FindNextRow", "CRowset.FindNextRow", "ATL::CRowset::FindNextRow", "CRowset::FindNextRow", "CRowset::FindNextRow", "CRowset.FindNextRow", "ATL.CRowset.FindNextRow", "ATL::CRowset::FindNextRow", "FindNextRow", "ATL::CRowset::GetApproximatePosition", "ATL::CRowset::GetApproximatePosition", "CRowset.GetApproximatePosition", "CRowset::GetApproximatePosition", "GetApproximatePosition", "ATL.CRowset.GetApproximatePosition", "CRowset::GetApproximatePosition", "CRowset::GetData", "ATL::CRowset::GetData", "ATL::CRowset::GetData", "ATL.CRowset.GetData", "CRowset.GetData", "CRowset::GetData", "CRowset.GetData", "ATL.CRowset.GetData", "CRowset::GetDataHere", "CRowset.GetDataHere", "CRowset.GetDataHere", "GetDataHere", "CRowset::GetDataHere", "ATL::CRowset::GetDataHere", "ATL::CRowset::GetDataHere", "ATL.CRowset.GetDataHere", "ATL.CRowset.GetDataHere", "ATL.CRowset.GetOriginalData", "CRowset::GetOriginalData", "ATL::CRowset::GetOriginalData", "ATL.CRowset.GetOriginalData", "CRowset::GetOriginalData", "ATL::CRowset::GetOriginalData", "CRowset.GetOriginalData", "CRowset.GetRowStatus", "ATL.CRowset.GetRowStatus", "ATL::CRowset::GetRowStatus", "CRowset::GetRowStatus", "ATL::CRowset::GetRowStatus", "CRowset::GetRowStatus", "ATL.CRowset.GetRowStatus", "CRowset.GetRowStatus", "ATL.CRowset.Insert", "CRowset.Insert", "CRowset.Insert", "CRowset::Insert", "ATL::CRowset::Insert", "ATL.CRowset.Insert", "CRowset::Insert", "ATL::CRowset::Insert", "CRowset::IsSameRow", "CRowset.IsSameRow", "ATL::CRowset::IsSameRow", "ATL.CRowset.IsSameRow", "CRowset::IsSameRow", "ATL.CRowset.IsSameRow", "CRowset.IsSameRow", "ATL::CRowset::IsSameRow", "CRowset::MoveFirst", "ATL::CRowset::MoveFirst", "CRowset.MoveFirst", "CRowset::MoveFirst", "CRowset.MoveFirst", "ATL.CRowset.MoveFirst", "ATL.CRowset.MoveFirst", "ATL::CRowset::MoveFirst", "ATL::CRowset::MoveLast", "CRowset::MoveLast", "ATL.CRowset.MoveLast", "ATL::CRowset::MoveLast", "CRowset.MoveLast", "CRowset::MoveLast", "ATL.CRowset.MoveLast", "CRowset.MoveLast", "ATL.CRowset.MoveNext", "ATL.CRowset.MoveNext", "ATL::CRowset::MoveNext", "CRowset.MoveNext", "CRowset.MoveNext", "CRowset::MoveNext", "CRowset::MoveNext", "ATL::CRowset::MoveNext", "CRowset.MovePrev", "CRowset.MovePrev", "CRowset::MovePrev", "ATL.CRowset.MovePrev", "ATL::CRowset::MovePrev", "ATL::CRowset::MovePrev", "ATL.CRowset.MovePrev", "CRowset::MovePrev", "ATL::CRowset::MoveToBookmark", "ATL::CRowset::MoveToBookmark", "ATL.CRowset.MoveToBookmark", "ATL.CRowset.MoveToBookmark", "CRowset::MoveToBookmark", "CRowset.MoveToBookmark", "CRowset::MoveToBookmark", "CRowset::MoveToRatio", "CRowset::MoveToRatio", "CRowset.MoveToRatio", "ATL.CRowset.MoveToRatio", "ATL::CRowset::MoveToRatio", "CRowset.MoveToRatio", "ATL.CRowset.MoveToRatio", "ATL::CRowset::MoveToRatio", "CRowset::ReleaseRows", "ATL::CRowset::ReleaseRows", "CRowset.ReleaseRows", "CRowset.ReleaseRows", "ATL.CRowset.ReleaseRows", "ATL.CRowset.ReleaseRows", "CRowset::ReleaseRows", "ATL::CRowset::ReleaseRows", "ATL.CRowset.SetData", "ATL::CRowset::SetData", "CRowset.SetData", "CRowset::SetData", "ATL.CRowset.SetData", "CRowset.SetData", "CRowset::SetData", "ATL::CRowset::SetData", "CRowset.Undo", "ATL::CRowset::Undo", "CRowset::Undo", "ATL.CRowset.Undo", "ATL.CRowset.Undo", "CRowset.Undo", "ATL::CRowset::Undo", "CRowset::Undo", "Undo", "CRowset.Update", "ATL.CRowset.Update", "ATL.CRowset.Update", "ATL::CRowset::Update", "CRowset::Update", "CRowset::Update", "CRowset.Update", "ATL::CRowset::Update", "CRowset::UpdateAll", "ATL.CRowset.UpdateAll", "CRowset.UpdateAll", "ATL.CRowset.UpdateAll", "UpdateAll", "CRowset.UpdateAl", "ATL::CRowset::UpdateAll", "CRowset::UpdateAll", "ATL::CRowset::UpdateAll"] helpviewer_keywords: ["CRowset class", "AddRefRows method", "Close method", "Compare method", "CRowset class, constructor", "Delete method", "FindNextRow method", "GetApproximatePosition method", "GetData method [OLE DB]", "GetDataHere method", "GetOriginalData method", "GetRowStatus method", "Insert method", "IsSameRow method", "MoveFirst method", "MoveLast method", "MoveNext method", "MovePrev method", "MoveToBookmark method", "MoveToRatio method", "ReleaseRows method", "SetData method", "Undo method", "Update method", "UpdateAll method"] ms.assetid: b0228a90-b8dd-47cc-b397-8d4c15c1e7f4 --- # CRowset Class Encapsulates an OLE DB rowset object and several related interfaces and provides manipulation methods for rowset data. ## Syntax ```cpp template class CRowset ``` ### Parameters *TAccessor*
An accessor class. The default is `CAccessorBase`. ## Requirements **Header:** atldbcli.h ## Members ### Methods | Name | Description | |-|-| |[AddRefRows](#addrefrows)|Increments the reference count associated with the current row.| |[Close](#close)|Releases rows and the current `IRowset` interface.| |[Compare](#compare)|Compares two bookmarks using [IRowsetLocate::Compare](/previous-versions/windows/desktop/ms709539(v=vs.85)).| |[CRowset](#crowset)|Creates a new `CRowset` object and (optionally) associates it with an `IRowset` interface supplied as a parameter.| |[Delete](#delete)|Deletes rows from the rowset using [IRowsetChange:DeleteRows](/previous-versions/windows/desktop/ms724362(v=vs.85)).| |[FindNextRow](#findnextrow)|Finds the next matching row after the specified bookmark.| |[GetApproximatePosition](#getapproximateposition)|Returns the approximate position of a row corresponding to a bookmark.| |[GetData](#getdata)|Retrieves data from the rowset's copy of the row.| |[GetDataHere](#getdatahere)|Retrieves data from the specified buffer.| |[GetOriginalData](#getoriginaldata)|Retrieves the data most recently fetched from or transmitted to the data source, ignoring pending changes.| |[GetRowStatus](#getrowstatus)|Returns the status of all rows.| |[Insert](#insert)|Creates and inserts a new row using [IRowsetChange:InsertRow](/previous-versions/windows/desktop/ms716921(v=vs.85)).| |[IsSameRow](#issamerow)|Compares the specified row with the current row.| |[MoveFirst](#movefirst)|Repositions the next-fetch location to the initial position.| |[MoveLast](#movelast)|Moves to the last record.| |[MoveNext](#movenext)|Fetches data from the next sequential row or a specified number of positions beyond the next row.| |[MovePrev](#moveprev)|Moves to the previous record.| |[MoveToBookmark](#movetobookmark)|Fetches the row marked by a bookmark or the row at a specified offset from that bookmark.| |[MoveToRatio](#movetoratio)|Fetches rows starting from a fractional position in the rowset.| |[ReleaseRows](#releaserows)|Calls [IRowset::ReleaseRows](/previous-versions/windows/desktop/ms719771(v=vs.85)) to release the current row handle.| |[SetData](#setdata)|Sets data values in one or more columns of a row using [IRowsetChange:SetData](/previous-versions/windows/desktop/ms721232(v=vs.85)).| |[Undo](#undo)|Undoes any changes made to a row since the last fetch or [Update](#update).| |[Update](#update)|Transmits any pending changes made to the current row since the last fetch or update.| |[UpdateAll](#updateall)|Transmits any pending changes made to all rows since the last fetch or update.| ## Remarks In OLE DB, a rowset is the object through which a program sets and retrieves data. This class is not meant to be instantiated but rather passed as a template parameter to `CTable` or `CCommand` (`CRowset` is the default). ## CRowset::AddRefRows Calls [IRowset::AddRefRows](/previous-versions/windows/desktop/ms719619(v=vs.85)) to increment (by one) the reference count associated with the current row handle. ### Syntax ```cpp HRESULT AddRefRows() throw(); ``` ### Return Value A standard HRESULT. ### Remarks This method increments the reference count for the current row handle. Call [ReleaseRows](#releaserows) to decrement the count. Rows returned by the move methods have a reference count of one. ## CRowset::Close Releases rows and the current [IRowset](/previous-versions/windows/desktop/ms720986(v=vs.85)) interface. ### Syntax ```cpp void Close() throw(); ``` ### Remarks This method releases all rows currently in the rowset. ## CRowset::Compare Compares two bookmarks using [IRowsetLocate::Compare](/previous-versions/windows/desktop/ms709539(v=vs.85)). ### Syntax ```cpp HRESULT Compare(const CBookmarkBase& bookmark1, const CBookmarkBase& bookmark2, DBCOMPARE* pComparison) const throw(); ``` #### Parameters *Bookmark1*
[in] The first bookmark to compare. *Bookmark2*
[in] The second bookmark to compare. *pComparison*
[out] A pointer to the result of the comparison. ### Return Value A standard HRESULT. ### Remarks This method requires the optional interface `IRowsetLocate`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetLocate` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. For information about using bookmarks in consumers, see [Using Bookmarks](../../data/oledb/using-bookmarks.md). ## CRowset::CRowset Creates a new `CRowset` object and (optionally) associates it with an [IRowset](/previous-versions/windows/desktop/ms720986(v=vs.85)) interface supplied as a parameter. ### Syntax ```cpp CRowset(); CRowset(IRowset* pRowset); ``` #### Parameters *pRowset*
[in] A pointer to an `IRowset` interface to be associated with this class. ## CRowset::Delete Calls [IRowsetChange::DeleteRows](/previous-versions/windows/desktop/ms724362(v=vs.85)) to delete the current row from the rowset. ### Syntax ```cpp HRESULT Delete() const throw(); ``` ### Return Value A standard HRESULT. ## CRowset::FindNextRow Finds the next matching row after the specified bookmark. ### Syntax ```cpp HRESULT FindNextRow(DBCOMPAREOP op, BYTE* pData, DBTYPE wType, DBLENGTH nLength, BYTE bPrecision, BYTE bScale, BOOL bSkipCurrent = TRUE, CBookmarkBase* pBookmark = NULL) throw(); ``` #### Parameters *op*
[in] The operation to use in comparing row values. For values, see [IRowsetFind::FindNextRow](/previous-versions/windows/desktop/ms723091(v=vs.85)). *pData*
[in] A pointer to the value to be matched. *wType*
[in] Indicates the data type of the value part of the buffer. For information about type indicators, see [Data Types](/previous-versions/windows/desktop/ms723969(v=vs.85)) in the *OLE DB Programmer's Reference* in the Windows SDK. *nLength*
[in] The length, in bytes, of the consumer data structure allocated for the data value. For details, see the description of `cbMaxLen` in [DBBINDING Structures](/previous-versions/windows/desktop/ms716845(v=vs.85)) in the *OLE DB Programmer's Reference.* *bPrecision*
[in] The maximum precision used when getting data. Used only if *wType* is DBTYPE_NUMERIC. For more information, see [Conversions involving DBTYPE_NUMERIC or DBTYPE_DECIMAL](/previous-versions/windows/desktop/ms719714(v=vs.85)) in the *OLE DB Programmer's Reference*. *bScale*
[in] The scale used when getting data. Used only if *wType* is DBTYPE_NUMERIC or DBTYPE_DECIMAL. For more information, see [Conversions involving DBTYPE_NUMERIC or DBTYPE_DECIMAL](/previous-versions/windows/desktop/ms719714(v=vs.85)) in the *OLE DB Programmer's Reference*. *bSkipCurrent*
[in] The number of rows from the bookmark at which to start a search. *pBookmark*
[in] The bookmark for position at which to start a search. ### Return Value A standard HRESULT. ### Remarks This method requires the optional interface `IRowsetFind`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetFind` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. For information about using bookmarks in consumers, see [Using Bookmarks](../../data/oledb/using-bookmarks.md). ## CRowset::GetApproximatePosition Returns the approximate position of a row corresponding to a bookmark. ### Syntax ```cpp HRESULT GetApproximatePosition(const CBookmarkBase* pBookmark, DBCOUNTITEM* pPosition, DBCOUNTITEM* pcRows) throw(); ``` #### Parameters *pBookmark*
[in] A pointer to a bookmark that identifies the row whose position is to be found. NULL if only the row count is required. *pPosition*
[out] A pointer to the location where `GetApproximatePosition` returns the position of the row. NULL if the position is not required. *pcRows*
[out] A pointer to the location where `GetApproximatePosition` returns the total number of rows. NULL if the row count is not required. ### Return Value A standard HRESULT. ### Remarks This method requires the optional interface `IRowsetScroll`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetScroll` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. For information about using bookmarks in consumers, see [Using Bookmarks](../../data/oledb/using-bookmarks.md). ## CRowset::GetData Retrieves data from the rowset's copy of the row. ### Syntax ```cpp HRESULT GetData() throw(); HRESULT GetData(int nAccessor) throw(); ``` #### Parameters *nAccessor*
[in] The (zero-offset) index number of the accessor to use for accessing the data. ### Return Value A standard HRESULT. ### Remarks If you specify an accessor that is not an autoaccessor in [BEGIN_ACCESSOR](./macros-and-global-functions-for-ole-db-consumer-templates.md#begin_accessor), use this method to explicitly get the data by passing the accessor number. ## CRowset::GetDataHere Retrieves data from the current row and places it into the specified buffer. ### Syntax ```cpp HRESULT GetDataHere(int nAccessor, void* pBuffer) throw(); ``` #### Parameters *nAccessor*
[in] The index number of the accessor to use for accessing the data. *pBuffer*
[out] A buffer into which to place the data for the current record. ### Return Value A standard HRESULT. ### Remarks For an example of how to use this function, see the [MultiRead sample](../../overview/visual-cpp-samples.md). ## CRowset::GetOriginalData Calls `IRowsetUpdate::GetOriginalData` to retrieve the data most recently fetched from or transmitted to the data source. ### Syntax ```cpp HRESULT GetOriginalData() throw(); ``` ### Return Value A standard HRESULT. ### Remarks This method retrieves the data most recently fetched from or transmitted to the data source; it does not retrieve values based on pending changes. This method requires the optional interface `IRowsetUpdate`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetUpdate` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. ## CRowset::GetRowStatus Returns the status of all rows. ### Syntax ```cpp HRESULT GetRowStatus(DBPENDINGSTATUS* pStatus) const throw(); ``` #### Parameters *pStatus*
[out] A pointer to a location where `GetRowStatus` returns the status value. See DBPENDINGSTATUS in the OLE DB Programmer's Reference. ### Return Value A standard HRESULT. ### Remarks This method requires the optional interface `IRowsetUpdate`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetUpdate` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. ## CRowset::Insert Creates and initializes a new row using data from the accessor. ### Syntax ```cpp HRESULT Insert(int nAccessor = 0, bool bGetHRow = false) throw(); ``` #### Parameters *nAccessor*
[in] The number of the accessor to use for inserting the data. *bGetHRow*
[in] Indicates whether the handle for the inserted row is retrieved. ### Return Value A standard HRESULT. ### Remarks This method requires the optional interface `IRowsetChange`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetChange` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. Insert might fail if one or more columns is not writable. Modify your cursor map to correct this. ### Example The following example shows how to access a data source through a rowset and then insert a string using a table in that rowset. First, create a table class by inserting a New ATL Object into your project. For example, right-click the project in the Workspace pane and select **New ATL Object**. From the **Data Access** category, select **Consumer**. Create a consumer object of type **Table**. (Selecting **Table** creates a rowset directly from the table; selecting **Command** creates a rowset through a SQL command.) Select a data source, specifying a table through which to access that data source. If you call your consumer object **CCustomerTable**, you would then implement your insertion code as follows: [!code-cpp[NVC_OLEDB_Consumer#10](../../data/oledb/codesnippet/cpp/crowset-insert_1.cpp)] ## CRowset::IsSameRow Compares the specified row with the current row. ### Syntax ```cpp HRESULT IsSameRow(HROW hRow) const throw(); ``` #### Parameters *hRow*
[in] A handle to the row to compare to the current row. ### Return Value A standard HRESULT. S_OK indicates the rows are the same. For other values, see [IRowsetIndentity::IsSameRow](/previous-versions/windows/desktop/ms719629(v=vs.85)) in the *OLE DB Programmer's Reference* in the Windows SDK. ## CRowset::MoveFirst Moves the cursor to the initial position and retrieves the initial row. ### Syntax ```cpp HRESULT MoveFirst() throw(); ``` ### Return Value A standard HRESULT. ### Remarks Calls [IRowset::RestartPosition](/previous-versions/windows/desktop/ms712877(v=vs.85)) to reposition the next-fetch location to the initial position (the position that was the next-fetch location when the rowset was created) and retrieves the initial row. ## CRowset::MoveLast Moves the cursor to the last row. ### Syntax ```cpp HRESULT MoveLast() throw(); ``` ### Return Value A standard HRESULT. ### Remarks Calls [IRowset::RestartPosition](/previous-versions/windows/desktop/ms712877(v=vs.85)) to reposition the next-fetch location to the last position and retrieves the last row. This method requires that you set `DBPROP_CANSCROLLBACKWARDS` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. (For better performance, you might also set `DBPROP_QUICKRESTART` to VARIANT_TRUE.) ## CRowset::MoveNext Moves the cursor to the next record. ### Syntax ```cpp HRESULT MoveNext() throw(); HRESULT MoveNext(LONG lSkip, bool bForward= true) throw(); ``` #### Parameters *lSkip*
[in] The number of rows to skip before fetching. *bForward*
[in] Pass **`true`** to move forward to the next record, **`false`** to move backward. ### Return Value A standard HRESULT. When the end of the rowset has been reached, returns DB_S_ENDOFROWSET. ### Remarks Fetches the next sequential row from the `CRowset` object, remembering the previous position. Optionally, you can choose to skip ahead *lSkip* rows or move backward. This method requires that you set the following properties before calling `Open` on the table or command containing the rowset: - `DBPROP_CANSCROLLBACKWARDS` must be VARIANT_TRUE if *lSkip* < 0 - `DBPROP_CANFETCHBACKWARDS` must be VARIANT_TRUE if *bForward* = false Otherwise (if *lSkip* >= 0 and *bForward* = true), you do not need to set any additional properties. ## CRowset::MovePrev Moves the cursor to the previous record. ### Syntax ```cpp HRESULT MovePrev() throw(); ``` ### Return Value A standard HRESULT. ### Remarks This method requires that you set either `DBPROP_CANFETCHBACKWARDS` or `DBPROP_CANSCROLLBACKWARDS` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. ## CRowset::MoveToBookmark Fetches the row marked by a bookmark or the row at a specified offset (*lSkip*) from that bookmark. ### Syntax ```cpp HRESULT MoveToBookmark(const CBookmarkBase& bookmark, LONG lSkip = 0) throw(); ``` #### Parameters *bookmark*
[in] A bookmark marking the location from which you want to fetch data. *lSkip*
[in] The number count of rows from the bookmark to the target row. If *lSkip* is zero, the first row fetched is the bookmarked row. If *lSkip* is 1, the first row fetched is the row after the bookmarked row. If *lSkip* is -1, the first row fetched is the row before the bookmarked row. ### Return Value A standard HRESULT. ### Remarks This method requires the optional interface `IRowsetLocate`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetLocate` to VARIANT_TRUE and set `DBPROP_CANFETCHBACKWARDS` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. For information about using bookmarks in consumers, see [Using Bookmarks](../../data/oledb/using-bookmarks.md). ## CRowset::MoveToRatio Fetches rows starting from a fractional position in the rowset. ### Syntax ```cpp HRESULT MoveToRatio(DBCOUNTITEM nNumerator, DBCOUNTITEM nDenominator,bool bForward = true) throw(); ``` #### Parameters *nNumerator*
[in] The numerator used to determine the fractional positional from which to fetch data. *nDenominator*
[in] The denominator used to determine the fractional positional from which to fetch data. *bForward*
[in] Indicates whether to move forward or backward. The default is forward. ### Return Value A standard HRESULT. ### Remarks `MoveToRatio` fetches rows according roughly to the following formula: `(nNumerator * RowsetSize ) / nDenominator` where `RowsetSize` is the size of the rowset, measured in rows. The accuracy of this formula depends on the specific provider. For details, see [IRowsetScroll::GetRowsAtRatio](/previous-versions/windows/desktop/ms709602(v=vs.85)). This method requires the optional interface `IRowsetScroll`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetScroll` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. ## CRowset::ReleaseRows Calls [IRowset::ReleaseRows](/previous-versions/windows/desktop/ms719771(v=vs.85)) to release the current row handle. ### Syntax ```cpp HRESULT ReleaseRows() throw(); ``` ### Return Value A standard HRESULT. ## CRowset::SetData Sets data values in one or more columns of a row. ### Syntax ```cpp HRESULT SetData() const throw(); HRESULT SetData(int nAccessor) const throw(); ``` #### Parameters *nAccessor*
[in] The number of the accessor to use for accessing the data. ### Return Value A standard HRESULT. ### Remarks For the `SetData` form that accepts no arguments, all accessors are used for updating. You typically call `SetData` to set data values in columns in a row, then call [Update](#update) to transmit those changes. This method requires the optional interface `IRowsetChange`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetChange` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. The setting operation might fail if one or more columns is not writable. Modify your cursor map to correct this. ## CRowset::Undo Undoes any changes made to a row since the last fetch or [Update](#update). ### Syntax ```cpp HRESULT Undo(DBCOUNTITEM* pcRows = NULL, HROW* phRow = NULL, DBROWSTATUS* pStatus = NULL) throw(); ``` #### Parameters *pcRows*
[out] A pointer to the location where `Undo` returns the number of rows it attempted to undo if required. *phRow*
[out] A pointer to the location where `Undo` returns an array of handles to all rows it attempted to undo if required. *pStatus*
[out] A pointer to the location where `Undo` returns the row status value. No status is returned if *pStatus* is null. ### Return Value A standard HRESULT. ### Remarks This method requires the optional interface `IRowsetUpdate`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetUpdate` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. ## CRowset::Update Transmits any pending changes made to the current row since the last fetch or `Update` call on it. ### Syntax ```cpp HRESULT Update(DBCOUNTITEM* pcRows = NULL, HROW* phRow = NULL, DBROWSTATUS* pStatus = NULL) throw(); ``` #### Parameters *pcRows*
[out] A pointer to the location where `Update` returns the number of rows it attempted to update, if required. *phRow*
[out] A pointer to the location where `Update` returns the handle of the row it attempted to update. No handle is returned if *phRow* is null. *pStatus*
[out] A pointer to the location where `Update` returns the row status value. No status is returned if *pStatus* is null. ### Return Value A standard HRESULT. ### Remarks Transmits any pending changes made to the current row since that row was last fetched or updated (using `Update` or [UpdateAll](#updateall)). You typically call [SetData](#setdata) to set data values in columns in a row, and then call `Update` to transmit those changes. This method requires the optional interface `IRowsetUpdate`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetUpdate` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. ## CRowset::UpdateAll Transmits any pending changes made to all rows since the last fetch or `Update` call on it. ### Syntax ```cpp HRESULT UpdateAll(DBCOUNTITEM* pcRows = NULL, HROW** pphRow = NULL, DBROWSTATUS** ppStatus = NULL) throw(); ``` #### Parameters *pcRows*
[out] A pointer to the location where `UpdateAll` returns the number of rows it attempted to update, if required. *pphRow*
[out] A pointer to memory in which `UpdateAll` returns the handle of the row it attempted to update. No handle is returned if *pphRow* is null. *ppStatus*
[out] A pointer to the location where `Update` returns the row status value. No status is returned if *ppStatus* is null. ### Remarks Transmits any pending changes made to all rows since those rows were last fetched or updated using [Update](#update) or `UpdateAll`. `UpdateAll` will update every row that has been modified, regardless of whether you still have the handle for them (see *pphRow*) or not. For example, if you used `Insert` to insert five rows in a rowset, you could either call `Update` five times or call `UpdateAll` once to update them all. This method requires the optional interface `IRowsetUpdate`, which might not be supported on all providers; if this is the case, the method returns E_NOINTERFACE. You must also set `DBPROP_IRowsetUpdate` to VARIANT_TRUE before calling `Open` on the table or command containing the rowset. ### Return Value A standard HRESULT. ## See also [DBViewer Sample](../../overview/visual-cpp-samples.md)
[MultiRead Sample](../../overview/visual-cpp-samples.md)
[MultiRead Attributes Sample](../../overview/visual-cpp-samples.md)
[OLE DB Consumer Templates](../../data/oledb/ole-db-consumer-templates-cpp.md)
[OLE DB Consumer Templates Reference](../../data/oledb/ole-db-consumer-templates-reference.md)