CODBCStmt.UpdateRecordmethod
Updates a record.
Syntax
FUNCTION UpdateRecord (BYVAL wRow AS SQLSETPOSIROW = 1) AS SQLRETURN
Parameters
| Name | Description | |
|---|---|---|
wRow | Optional. Row number inside the rowset. Note: wRow is the row number inside the rowset (if the rowset has only one row, then wRow must be always 1). |
Return value
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NEED_DATA, SQL_STILL_EXECUTING, SQL_ERROR, or SQL_INVALID_HANDLE.
Description
The driver positions the cursor in the row specified by wRow and updates the underlying row of data with the values in the rowset buffers (the TargetValue argument in BindCol). It retrieves the lengths of the data from the length indicator buffers (the StrLen_or_Ind argument in BindCol). If the length of any column is SQL_COLUMN_IGNORE, the column is not updated. After updating the row, the driver changes the corresponding element of the row status array to SQL_ROW_UPDATED or SQL_ROW_ACCESS_WITH_INFO (if the row status array exists).
Example
#include once "AfxNova/COdbc.inc" USING AfxNova
' // Connect with the database DIM wszConStr AS WSTRING * 260 = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=biblio.mdb" DIM pDbc AS CODBC = wszConStr
' // Allocate an statement object DIM pStmt AS COdbcStmt = @pDbc IF pStmt.Handle = NULL THEN PRINT "Failed to allocate the statement handle": SLEEP : END
' // Cursor type pStmt.SetMultiuserKeysetCursor
' // Bind the columns DIM AS LONG lAuId, cbAuId pStmt.BindCol(1, @lAuId, @cbAuId) DIM wszAuthor AS WSTRING * 256, cbAuthor AS LONG pStmt.BindCol(2, @wszAuthor, 256, @cbAuthor) DIM iYearBorn AS SHORT, cbYearBorn AS LONG pStmt.BindCol(3, @iYearBorn, @cbYearBorn)
' // Generate a result set pStmt.ExecDirect ("SELECT * FROM Authors WHERE Au_Id=999")
' // Fetch the record pstmt.Fetch
' // Fill the values of the binded application variables and its sizes cbAuID = SQL_COLUMN_IGNORE wszAuthor = "Félix Lope de Vega Carpio" cbAuthor = LEN(wszAuthor) * 2 ' Unicode uses 2 bytes per character iYearBorn = 1562 cbYearBorn = SIZEOF(iYearBorn)
' // Update the record pStmt.UpdateRecord IF pStmt.Error = FALSE THEN PRINT "Record updated" ELSE PRINT pStmt.GetErrorInfo
Reference
- Include file
CODBCStmt.inc - Defined in AfxNova/COdbcStmt.inc:713
- Documented in Databases/ODBC Classes/CODBCStmt Class.md
- Topic: CODBCStmt Class