C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




please give me Transaction code using asp.net with c#(code behind page) and sql code also


Posted Date: 29 Aug 2006      Total Responses: 2

Posted By: vasusen       Member Level: Gold     Points: 2


please give me Transaction code using asp.net with c#(code behind page) and sql code also



Responses

Author: Zeeshan Pervez    29 Aug 2006Member Level: SilverRating:     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 2006Member Level: SilverRating:     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





Post Reply
You must Sign In to post a response.
Next : Cookie
Previous : what is use of VaryByParam
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

Help Desk

Contact Us    Privacy Policy    Terms Of Use