Help Center

CODBCStmt.DeleteRecordmethod

Deletes the specified row of data.

DatabasesmethodCODBCStmt.incdocumented

Syntax

FUNCTION DeleteRecord (BYVAL wRow AS SQLSETPOSIROW = 1) AS SQLRETURN

Parameters

NameDescription
RowNumberRow number inside the rowset. Note: RowNumber is the row number inside the rowset (if it is a single row rowset, RowNumber 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 on the row specified by RowNumber and deletes the underlying row of data. It changes the corresponding element of the row status array to SQL_ROW_DELETED. After the row has been deleted, the following are not valid for the row: positioned update and delete statements, calls to GetData and calls to SetPos with Operation set to anything except SQL_POSITION. For drivers that support packing, the row is deleted from the cursor when new data is retrieved from the data source. Whether the row remains visible depends on the cursor type. For example, deleted rows are visible to static and keyset-driven cursors but invisible to dynamic cursors. The row operation array pointed to by the SQL_ATTR_ROW_OPERATION_PTR statement attribute can be used to indicate that a row in the current rowset should be ignored during a bulk delete.

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)

' // Delete the record pStmt.DeleteRecord IF pStmt.Error = FALSE THEN PRINT "Record deleted" ELSE PRINT pStmt.GetErrorInfo

Reference

  • Include file CODBCStmt.inc
  • Defined in AfxNova/COdbcStmt.inc:758
  • Documented in Databases/ODBC Classes/CODBCStmt Class.md
  • Topic: CODBCStmt Class