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



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Create a transaction in ADO.NET and commit or rollback


Posted Date: 23 Apr 2007    Resource Type: Code Snippets    Category: ADO.NET

Posted By: Balamurali Balaji       Member Level: Diamond
Rating:     Points: 10



The following code sample shows how to run a query within a transaction using ADO.NET so that other users of the database do not have access to the table.



SqlConnection conn = new SqlConnection("Data Source=.;Integrated Security=true; Initial Catalog=pubs");
SqlCommand comm = new SqlCommand("select au_id from authors", conn);
conn.Open();
comm.Transaction = conn.BeginTransaction(IsolationLevel.RepeatableRead);
SqlDataReader dr = comm.ExecuteReader();
while (dr.Read())
{
MessageBox.Show (dr[0].ToString());
}
comm.Transaction.Commit();
conn.Close();







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Pass NULL as a Parameter Value to SQLParameter
Previous Resource: Store the changes in the dataset as XML Diffgram
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use