| Author: Zeeshan Pervez 29 Aug 2006 | Member Level: Silver | Rating: Points: 2 |
It will be bit difficult for you understand someone else logic :( . So here i am providing the simple example to using SqlTransactionin c#.Net
using System.Data; using System.Data.SqlClient;
On button Click Event Strat the transaction try { // Declare Transaction SqlTransaction trns; // Open sql Connection con.Open(); // Begion Transaction trns = con.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted); // Here will be you applicaton logic // you can Execute Quries and so on // Note : You have to use the same connection with each command // After of the command has executed then commit the Trans..... Other wise roll //back it trns.Commit(); } catch { trns.Rollback(); // Error Mesaage Login } finally { con.Close(); }
Feel free to contact (I can also provide you the code if it is difficult for you to under stand)
happy coding Zeeshan PERVEZ
|
| Author: Zeeshan Pervez 01 Sep 2006 | Member Level: Silver | Rating: Points: 2 |
-- First of all Begin the Transaction Begin Tran -- You DML (Insert , Update , Delete , Select ) Statement Insert into tbl_User(UserID , Name , Address , Age) Values(1,'Zeeshan','Lahore Pakistan' , 23) -- You can check @@Error after Every DML Statment -- and Rollback the Transaction if you find any Error IF @@Error <> 0 Begin RollBack RAISERROR('Error Occued in Inserting the Record' , 16 , 1) Return End -- If no Error Occured then Commit the Transaction COMMIT Tran
Happing Coding Zeeshan PERVEZ
|