PgSqlCommand Transaction

PgSqlCommand Transaction

Postby iquennell » Wed 01 Dec 2010 23:55

I am trying to find an answer to a rollback problem I am having. I am starting a transaction on a connection. Running multiple database commands (updates, inserts etc). Then committing the transaction. An error occurs during the commit. I have a try/catch that then requests a rollback. However no rollback occurs.

The PgSqlCommand statement has a Transaction property that the documentation states:

Gets or sets the DbTransaction within which this DbCommand object executes


Does this mean that if a command is executed without setting this property, the command is executed outside the current transaction even though it is executed after the begintransaction and before the commit ?

Could this be the cause of my problem? Has anyone else had this kind of problem when committing transactions?

Any advice/help would be gratefully received.
iquennell
 
Posts: 7
Joined: Wed 05 Jul 2006 09:31

Postby Shalex » Thu 02 Dec 2010 11:23

I have tried dotConnect for PostgreSQL v 5.0.58 with this sample in our online documentation. The corresponding DDL:
Code: Select all
CREATE TABLE DEPT (
  DEPTNO INT PRIMARY KEY,
  DNAME VARCHAR(14),
  LOC VARCHAR(13)
);

Commit() and Rollback() work as expected. Please try it in your environment. Tell us your version of dotConnect for PostgreSQL (the Tools > PostgreSQL > About menu of Visual Studio) and how we should modify this sample to reproduce the problem.

PgSqlCommand.Transaction is set automatically when you are starting local transaction on your connection object. So assigning pgCommand.Transaction to myTrans is not necessary in the sample. You can check this with our dbMonitor tool:
Download link: http://www.devart.com/dbmonitor/dbmon3.exe
Documentation: http://www.devart.com/dotconnect/postgr ... nitor.html
Shalex
Devart Team
 
Posts: 7781
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL