SqlTransaction Rollback
-
Hi, I am using a block of code to Import the Data to SQLServer2000
try
sqlTransaction sqlTran;
{
using (sqlTran = MyConnnection.BeginTansaction )
try
{
ImportData();
sqlTran.Commit();
}
catch(Exception ex)
{
sqlTran.Rollback()
}
}
catch
{}Now as the Process start's If in middle of the Process I close the Window the Process stop's, But the related tables in DB doesn't respond Is that because rollback() is not called.If yes then Is it possible to calls Rollback in such situation. Thanks Navneet Hegde
Develop2Program & Program2Develop
-
Hi, I am using a block of code to Import the Data to SQLServer2000
try
sqlTransaction sqlTran;
{
using (sqlTran = MyConnnection.BeginTansaction )
try
{
ImportData();
sqlTran.Commit();
}
catch(Exception ex)
{
sqlTran.Rollback()
}
}
catch
{}Now as the Process start's If in middle of the Process I close the Window the Process stop's, But the related tables in DB doesn't respond Is that because rollback() is not called.If yes then Is it possible to calls Rollback in such situation. Thanks Navneet Hegde
Develop2Program & Program2Develop
-
Try putting the rollback and commit in a FINALLY block and set an indicator so you know which to execute. FINALLY blocks are always executed.
Bob Ashfield Consultants Ltd
Thanks So, if I close my Application through Task maNager, Then before ending the process FINALLY will be executed.
Develop2Program & Program2Develop
-
Thanks So, if I close my Application through Task maNager, Then before ending the process FINALLY will be executed.
Develop2Program & Program2Develop
-
I doubt that! Why on earth do you want to close the application through the Task Manager?
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008):) anyway!! I wanted to be sure that my DB is not hanged in case of any eventuality.So Rollback is fired atleast.
Develop2Program & Program2Develop
-
Thanks So, if I close my Application through Task maNager, Then before ending the process FINALLY will be executed.
Develop2Program & Program2Develop
-
Hi, I am using a block of code to Import the Data to SQLServer2000
try
sqlTransaction sqlTran;
{
using (sqlTran = MyConnnection.BeginTansaction )
try
{
ImportData();
sqlTran.Commit();
}
catch(Exception ex)
{
sqlTran.Rollback()
}
}
catch
{}Now as the Process start's If in middle of the Process I close the Window the Process stop's, But the related tables in DB doesn't respond Is that because rollback() is not called.If yes then Is it possible to calls Rollback in such situation. Thanks Navneet Hegde
Develop2Program & Program2Develop
If the application terminates unexpectedly the connection will be closed and any transaction will be rolled back.
-
Try putting the rollback and commit in a FINALLY block and set an indicator so you know which to execute. FINALLY blocks are always executed.
Bob Ashfield Consultants Ltd
Ashfield wrote:
FINALLY blocks are always executed.
Not if the application is terminated outside its control, though I don't know why he's concerned about it.