| title | CRowset::Insert | Microsoft Docs | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ms.custom | ||||||||||||||
| ms.date | 11/04/2016 | |||||||||||||
| ms.reviewer | ||||||||||||||
| ms.suite | ||||||||||||||
| ms.technology |
|
|||||||||||||
| ms.tgt_pltfrm | ||||||||||||||
| ms.topic | article | |||||||||||||
| f1_keywords |
|
|||||||||||||
| dev_langs |
|
|||||||||||||
| helpviewer_keywords |
|
|||||||||||||
| ms.assetid | 6a64a1c3-10ac-4296-8685-0fd6fe63a13b | |||||||||||||
| caps.latest.revision | 10 | |||||||||||||
| author | mikeblome | |||||||||||||
| ms.author | mblome | |||||||||||||
| manager | ghogen | |||||||||||||
| translation.priority.ht |
|
Creates and initializes a new row using data from the accessor.
HRESULT Insert(
int nAccessor = 0,
bool bGetHRow = false
) throw( );
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.
A standard HRESULT.
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.
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-cppNVC_OLEDB_Consumer#10]
Header: atldbcli.h