dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersRaj.Trivedi
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » Code Snippets » ADO.NET

"BatchUpdate in Ado.net


Posted Date:     Category: ADO.NET    
Author: Member Level: Gold    Points: 3


In this we see what is BatchUpdate in Ado.net . Why it is used and how we can use it.



 


In the previous version of Ado.net DataAdapter sent command to the database one at a time , so if we want to update
large number of rows suppose 100 then DataAdapter would execute 50 separate operations against database. This decreases
the performance.

Ado.net provides a feature called Batch Update which can improve the performance of the data access layer by
reducing the number of roundtrips to the database. It can perform update for a set of row at a time.


For this DataAdapter has a property UpdateBatchSize. Setting this property a positive number causes update to the database
to be sent as batches of the specified size.




string connectionstring = "server=dell;initial catalog = employeedetail;uid = xyz;pwd= xyz";
SqlConnection con = new SqlConnection(connectionstring);
SqlDataAdapter adpt = new SqlDataAdapter("select * from Employee", con);
DataSet ds = new DataSet();
adpt.Fill(ds, "Employee");
SqlcommandBuilder cmd = new SqlcommandBuilder(adpt);
adpt.UpdateBatchSize = 5;
adpt.Update("Employee");


In this example we have set the BatchSize = 5 means at a time 5 rows can be updated.


Important Points:
1. Setting UpdateBatchSize= 1,disables batch updates.
2. Setting UpdateBatchSize= x,where x>1, sends x statement to the database at a time.
3. Setting UpdateBatchSize= 0,sends the maximum number of statements at a time alloted by server.





Did you like this resource? Share it with your friends and show your love!


Responses to ""BatchUpdate in Ado.net"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: What is the use of SqlBatchUpdate Class in ado.net
    Previous Resource: DataRelation class
    Return to Resources
    Post New Resource
    Category: ADO.NET


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Ado.net advance feature"  .  "BatchUpdate in Ado.net"  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.