471,122 Members | 1,114 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,122 software developers and data experts.

Rollback transaction doesnt work when DataAdapter.Update() throws exception caused by RAISEERROR in a trigger

Hi,

I have a trigger like this (simplified to illustrate the problem):

--------
CREATE TRIGGER Test ON [dbo].[TestTable]
FOR INSERT, UPDATE, DELETE
AS

RAISERROR( 'test trigger error !', 16, 1)
---------

And a C# code portion: (new record inserted in dsFormTest.TestTable)

---------
OdbcTransaction odbcTrans = null;

try {

if ( odbcConn.State != ConnectionState.Open ) odbcConn.Open();
odbcTrans = odbcConn.BeginTransaction();

odaTest.InsertCommand.Transaction = odbcTrans;
odaTest.Update( dsFormTest.TestTable );

odbcTrans.Commit();

}
catch( Exception xc ) {
if ( odbcTrans != null ) odbcTrans.Rollback();
MessageBox.Show( xc.ToString() );
}

odbcConn.Close();
----------

BUT, instead of rolling back transaction, the odbcTrans.Rollback() throws
new exception with message:

System.InvalidOperationException: RollbackTransaction requires an open and
available Connection. The connection's current state is Open, Fetching.

any clues why?
Jul 21 '05 #1
0 1680

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Alice | last post: by
1 post views Thread by anders_tung | last post: by
3 posts views Thread by level8 | last post: by
2 posts views Thread by mahajan.sanjeev | last post: by
15 posts views Thread by Zeng | last post: by
1 post views Thread by jacob.miles | last post: by
2 posts views Thread by Ian Boyd | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.