views:

172

answers:

4

I want to make sure that if any error occurs during the database processing phase, program will know it need to roll back the whole process.

any good ORM in MFC/C++ for doing this ?

+1  A: 

If you're connecting to a transactional database, like SQL Server, Oracle, PostgreSQL, Firebird, some of MySQL's data engines, etc. then they will have an API for transactions. Similarly, some non-SQL databases also have transactional semantics and an associated API (like Berkeley DB). Since you don't mention what database you're using, I really don't know what else to say.

Max Lybbert
+1  A: 

This has nothing to do with ORM. You want basic transaction functionality

If you're using MFC, then most likely you're working with your database either via CDatabase (ODBC), CDaoWorkspace/CDaoDatabase (DAO), or CDataConnection/CSession (OLE DB). If so, you should use CDatabase::Rollback, CDaoWorkspace::Rollback, or CSession::Abort, respectively.

Pavel Minaev
+2  A: 

The MFC _ConnectionPtr object has BeginTrans, CommitTrans and RollbackTrans methods.

http://msdn.microsoft.com/en-us/library/ms675942(VS.85).aspx

I wouldn't call it good though, you'd need to wrap it.

Patrick
in C++ - use RAII-Classes to wrap them. Constructor begins the transaction, destructor rollsback if no commit was applied before destruction.
Tobias Langner
A: 

Debea Database Library is an ORM for C++ - http://debea.net/

Lukasz