I am working on a Windows application (WinForms) that requires four different processes to run (stored procedures) that include the ability to commit or rollback the entire process in the instance that any of the four processes raised an error. I'll describe my situation below (and please excuse my SQL ignorance as I am not a DBA):
Windows App: Click Process Button
Database: Initiate Procedure 1 (and presumably BEGIN TRANSACTION MyProcessTransaction)
Windows App: Click Process Button
Database: Initiate Procedure 1 (and presumably BEGIN TRANSACTION MyProcessTransaction)
Windows App: Receives notification from Procedure 1 that it completed successfully and updates a progress bar.
Database: Initiate Procedure 2 (and somehow still encapsulated under MyProcessTransaction)
Windows App: Receives notification from Procedure 2 that it completed successfully and updates a progress bar.
- Database: Initiate Procedure 3 (and somehow still encapsulated under MyProcessTransaction) and raises an error and rolls back the transaction MyProcessTransaction
Is this possible? I tried four query windows and began a transaction in the first, then put try catches in the other windows and attempted to perform work in each to simulate this but when I got to the fourth window and intentionally raised an error, I received the exception that there was no BEGIN TRANSACTION for me to be able to ROLLBACK. Any suggestions?