Help Center

CODBC.RollbackTranmethod

RollbackTran requests a rollback operation for all active operations on all statements associated with an environment.

DatabasesmethodCODBCDbc.incdocumented

Syntax

FUNCTION RollbackTran () AS SQLRETURN

Return value

SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.

Description

Requests a rollback operation for all active operations on all statements associated with an environment.

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 * 260, 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 = 998 : 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

' // Commit the transaction ' pDbc.CommitTran ' IF pDbc.Error = FALSE THEN PRINT "Commit succeeded" ' or Rollbacks it because this is a test pDbc.RollbackTran IF pDbc.Error = FALSE THEN PRINT "Rollback succeeded" ELSE PRINT pDbc.GetErrorInfo

Reference

  • Include file CODBCDbc.inc
  • Defined in AfxNova/COdbcDbc.inc:195
  • Documented in Databases/ODBC Classes/CODBC Class.md
  • Topic: ODBC Classes