CODBCStmt.AddRecordmethod
Adds a record to the database.
Syntax
FUNCTION AddRecord () AS SQLRETURN
Return value
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NEED_DATA, SQL_STILL_EXECUTING, SQL_ERROR, or SQL_INVALID_HANDLE.
Description
Adds a record to the database.
Example
#include once "AfxNova/COdbc.inc" USING AfxNova
' // Create a connection object and connect with the database DIM wszConStr AS WSTRING * 260 = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=biblio.mdb" DIM pDbc AS CODBC = wszConStr IF pDbc.Handle = NULL THEN PRINT "Unable to create the connection handle" : SLEEP : END
' // Allocate an statement object DIM pStmt AS COdbcStmt = @pDbc IF pStmt.Handle = NULL THEN PRINT "Unable to create 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, SIZEOF(wszAuthor), @cbAuthor) DIM iYearBorn AS SHORT, cbYearBorn AS LONG pStmt.BindCol(3, @iYearBorn, @cbYearBorn)
' // Generate a result set pStmt.ExecDirect ("SELECT * FROM Authors ORDER BY Author")
' // Fill the values of the bounded application variables and its sizes lAuId = 999 : cbAuID = SIZEOF(lAuId) wszAuthor = "Edgar Allan Poe" : cbAuthor = LEN(wszAuthor) iYearBorn = 1809 : cbYearBorn = SIZEOF(iYearBorn) ' // Add the record pStmt.AddRecord IF pStmt.Error = FALSE THEN PRINT "Record added" ELSE PRINT pStmt.GetErrorInfo
Reference
- Include file
CODBCStmt.inc - Defined in AfxNova/COdbcStmt.inc:780
- Documented in Databases/ODBC Classes/CODBCStmt Class.md
- Topic: CODBCStmt Class