Hi;

I am trying to use nested transaction but getting
exception

System.InvalidOperationException: OleDbConnection does not
support parallel transactions.

Please help
Thanks

Here is my code...

OleDbConnection conn =
GetConnection();
if( conn.State ==
ConnectionState.Closed )
conn.Open();

OleDbTransaction T1 =
conn.BeginTransaction();

string sqlStr = "INSERT INTO
XFER_REC( XFERLST_NAME, XFERLST_DESCRIPTION, STYLE,
SOURCE )"

+ " VALUES ( 'Test', 'test', 1, 3 )";

OleDbCommand cmd = new OleDbCommand
( sqlStr, conn, T1 );
cmd.CommandType = CommandType.Text;

try
{
cmd.ExecuteNonQuery();

//Let's try to add record
inside child table...
if(conn.State ==
ConnectionState.Closed )
conn.Open();
OleDbTransaction T2 =
conn.BeginTransaction();
sqlStr = "INSERT INTO
XFER_DO_MEASURES(XR_XFER_ID, XDM_ID, DO_MEASURE )"

+ " VALUES ( 71, 25, 111 )";

cmd = new OleDbCommand(
sqlStr, conn, T2 );
cmd.CommandType =
CommandType.Text;

cmd.ExecuteNonQuery();

T2.Commit();
T1.Commit();
}
catch( Exception e )
{
T1.Rollback();

System.Diagnostics.Trace.Write( e.ToString() );
}

Re: OleDbConnection does not support parallel transactions by Charles

Charles
Wed Sep 03 18:09:52 CDT 2003

Hi Niraj

How about opening a second connection and starting a transaction on that for
the duration of the nested transaction?

HTH

Charles


"Niraj" <nshah@rudolphtech.com> wrote in message
news:0cf801c37265$012c2700$a001280a@phx.gbl...
> Hi;
>
> I am trying to use nested transaction but getting
> exception
>
> System.InvalidOperationException: OleDbConnection does not
> support parallel transactions.
>
> Please help
> Thanks
>
> Here is my code...
>
> OleDbConnection conn =
> GetConnection();
> if( conn.State ==
> ConnectionState.Closed )
> conn.Open();
>
> OleDbTransaction T1 =
> conn.BeginTransaction();
>
> string sqlStr = "INSERT INTO
> XFER_REC( XFERLST_NAME, XFERLST_DESCRIPTION, STYLE,
> SOURCE )"
>
> + " VALUES ( 'Test', 'test', 1, 3 )";
>
> OleDbCommand cmd = new OleDbCommand
> ( sqlStr, conn, T1 );
> cmd.CommandType = CommandType.Text;
>
> try
> {
> cmd.ExecuteNonQuery();
>
> //Let's try to add record
> inside child table...
> if(conn.State ==
> ConnectionState.Closed )
> conn.Open();
> OleDbTransaction T2 =
> conn.BeginTransaction();
> sqlStr = "INSERT INTO
> XFER_DO_MEASURES(XR_XFER_ID, XDM_ID, DO_MEASURE )"
>
> + " VALUES ( 71, 25, 111 )";
>
> cmd = new OleDbCommand(
> sqlStr, conn, T2 );
> cmd.CommandType =
> CommandType.Text;
>
> cmd.ExecuteNonQuery();
>
> T2.Commit();
> T1.Commit();
> }
> catch( Exception e )
> {
> T1.Rollback();
>
> System.Diagnostics.Trace.Write( e.ToString() );
> }
>



Re: OleDbConnection does not support parallel transactions by Niraj

Niraj
Thu Sep 04 08:28:07 CDT 2003

Hi Charles;

Thanks for your suggestion.
I was able to overcome parallel transaction exception
but I ran into another exception...

"Could not read the record; currently locked by another
user"

Seems like, In Access 2000 I have to close first
connection & then work on second one.
By doing so, I will not have nested transaction...

Following is part of code...

try
{
cmd.ExecuteNonQuery();
T1.Commit(); //This OleDbTransaction has
completed; it is no longer usable
conn.Close(); //Could not read the record;
currently locked by another user

//Let's try to add record inside child table...
OleDbConnection conn1 = ps.GetConnection();
if(conn1.State == ConnectionState.Closed )
conn1.Open();
OleDbTransaction T2 = conn1.BeginTransaction();
sqlStr = "INSERT INTO XFER_DO_MEASURES
(XR_XFER_ID, XDM_ID, DO_MEASURE )"
+ " VALUES ( 71,
25, 111 )";

cmd = new OleDbCommand( sqlStr, conn1, T2 );
cmd.CommandType = CommandType.Text;

cmd.ExecuteNonQuery();

T2.Commit();

}

Any suggestion?

Thanks again.
Niraj



>-----Original Message-----
>Hi Niraj
>
>How about opening a second connection and starting a
transaction on that for
>the duration of the nested transaction?
>
>HTH
>
>Charles
>
>
>"Niraj" <nshah@rudolphtech.com> wrote in message
>news:0cf801c37265$012c2700$a001280a@phx.gbl...
>> Hi;
>>
>> I am trying to use nested transaction but getting
>> exception
>>
>> System.InvalidOperationException: OleDbConnection does
not
>> support parallel transactions.
>>
>> Please help
>> Thanks
>>
>> Here is my code...
>>
>> OleDbConnection conn =
>> GetConnection();
>> if( conn.State ==
>> ConnectionState.Closed )
>> conn.Open();
>>
>> OleDbTransaction T1 =
>> conn.BeginTransaction();
>>
>> string sqlStr = "INSERT INTO
>> XFER_REC( XFERLST_NAME, XFERLST_DESCRIPTION, STYLE,
>> SOURCE )"
>>
>> + " VALUES ( 'Test', 'test', 1, 3 )";
>>
>> OleDbCommand cmd = new OleDbCommand
>> ( sqlStr, conn, T1 );
>> cmd.CommandType = CommandType.Text;
>>
>> try
>> {
>> cmd.ExecuteNonQuery();
>>
>> //Let's try to add record
>> inside child table...
>> if(conn.State ==
>> ConnectionState.Closed )
>> conn.Open();
>> OleDbTransaction T2 =
>> conn.BeginTransaction();
>> sqlStr = "INSERT INTO
>> XFER_DO_MEASURES(XR_XFER_ID, XDM_ID, DO_MEASURE )"
>>
>> + " VALUES ( 71, 25, 111 )";
>>
>> cmd = new OleDbCommand(
>> sqlStr, conn, T2 );
>> cmd.CommandType =
>> CommandType.Text;
>>
>> cmd.ExecuteNonQuery();
>>
>> T2.Commit();
>> T1.Commit();
>> }
>> catch( Exception e )
>> {
>> T1.Rollback();
>>
>> System.Diagnostics.Trace.Write( e.ToString() );
>> }
>>
>
>
>.
>

RE: OleDbConnection does not support parallel transactions by v-kevy

v-kevy
Thu Sep 04 09:14:28 CDT 2003

Thanks to Charles and David for providing good suggestion.

Niraj, Neither ODBC, nor any released OLE DB Provider, exposes Nested
Transaction functionality, even if the back-end data source supports this
feature.

See http://support.microsoft.com/default.aspx?scid=kb;en-us;177138 and
http://support.microsoft.com/default.aspx?scid=kb;en-us;313480 for more
information.

To workaround this problem, you can try to begin the next transaction in
another connection.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Re: OleDbConnection does not support parallel transactions by David

David
Thu Sep 04 09:55:38 CDT 2003


"Niraj" <nshah@rudolphtech.com> wrote in message
news:14ea01c372e8$607e1280$a001280a@phx.gbl...
> Hi Charles;
>
> Thanks for your suggestion.
> I was able to overcome parallel transaction exception
> but I ran into another exception...
>
> "Could not read the record; currently locked by another
> user"

Yeah, it's locked by your other connection.

This is why using 2 connections can't do everyting that nested transactions
can.


The good news is that it doesn't appear that you actually need nested
transactions.

this code:

OleDbTransaction T2 =
conn.BeginTransaction();
sqlStr = "INSERT INTO
XFER_DO_MEASURES(XR_XFER_ID, XDM_ID, DO_MEASURE )"

+ " VALUES ( 71, 25, 111 )";

cmd = new OleDbCommand(
sqlStr, conn, T2 );
cmd.CommandType =
CommandType.Text;

cmd.ExecuteNonQuery();

T2.Commit();

will run the same with or without a transaction. A single insert statement
is always atomic so running it in its own transaction is redundant.

David



Re: OleDbConnection does not support parallel transactions by Charles

Charles
Thu Sep 04 10:24:35 CDT 2003

Hi Kevin

Of the two articles you have referenced, I believe that only the second
relates to ADO.NET and the .NET Framework. In it, just below half way
(section "Transactions"), it seems to suggest that nested transactions _are_
supported. Is that the way you read it?

Charles


"Kevin Yu" <v-kevy@online.microsoft.com> wrote in message
news:mYO7u7ucDHA.2244@cpmsftngxa06.phx.gbl...
> Thanks to Charles and David for providing good suggestion.
>
> Niraj, Neither ODBC, nor any released OLE DB Provider, exposes Nested
> Transaction functionality, even if the back-end data source supports this
> feature.
>
> See http://support.microsoft.com/default.aspx?scid=kb;en-us;177138 and
> http://support.microsoft.com/default.aspx?scid=kb;en-us;313480 for more
> information.
>
> To workaround this problem, you can try to begin the next transaction in
> another connection.
>
> If anything is unclear, please feel free to reply to the post.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>