Cannot assign transaction to a DbCommand

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
jip
Posts: 1
Joined: Tue 14 Apr 2009 07:07

Cannot assign transaction to a DbCommand

Post by jip » Thu 16 Apr 2009 09:48

Is this a licencing issue ? :

Code: Select all

DbTransaction t = null;
t = conn.BeginTransaction(IsolationLevel.Serializable);  //t correctly assigned

dbCmd.Transaction = t;  //dbCmd.Transaction stays null
(
Also just for notice:
Setting IsolationLevel to 'Chaos' throwns an exception:

Code: Select all

Une exception de première chance de type 'Devart.Data.PostgreSql.PgSqlException' s'est produite dans Devart.Data.PostgreSql.dll

Devart.Data.PostgreSql.PgSqlException: syntax error at end of input
   à Devart.Data.PostgreSql.s.d(Boolean A_0)
   à Devart.Data.PostgreSql.s.af()
   à Devart.Data.PostgreSql.s.b(String A_0)
   à Devart.Data.PostgreSql.s.l()
   à Devart.Data.PostgreSql.PgSqlCommand.InternalPrepare(Boolean implicitPrepare, Int32 startRecord, Int32 maxRecords)
   à Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
   à System.Data.Common.DbCommand.ExecuteReader()
   à Devart.Common.DbCommandBase.ExecuteNonQuery()
   à Devart.Data.PostgreSql.PgSqlTransaction..ctor(PgSqlConnection A_0, IsolationLevel A_1)
   à Devart.Data.PostgreSql.m.a(IsolationLevel A_0)
   à Devart.Common.DbConnectionBase.BeginDbTransaction(IsolationLevel isolationLevel)
   à System.Data.Common.DbConnection.BeginTransaction(IsolationLevel isolationLevel)
)

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 16 Apr 2009 13:04

The Transaction property of PgSqlCommand has only getter at the moment (it has no setter). So, it can be used for reading its value only. Setting of this property is executed when assinging the PgSqlConnection object that has the opened transaction. For example:

Code: Select all

  PgSqlConnection pgConnection = new PgSqlConnection(myConnString); 
  pgConnection.Open(); 
  PgSqlCommand pgCommand = new PgSqlCommand(); 
  PgSqlTransaction myTrans; 
  // Start a local transaction 
  myTrans = pgConnection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); 
  // Assign transaction object for a pending local transaction 
  pgCommand.Connection = pgConnection; //pgCommand.Transaction is assigned now
...
IsolationLevel.Chaos is not supported at the moment. The following isolation levels are supported by dotConnect for PostgreSQL:
  • ReadCommitted (default)
    Serializable
    ReadUncommitted
    RepeatableRead
For more information please refer to our online documentation: http://www.devart.com/dotconnect/postgresql/docs/ .

Post Reply