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 !




commandBuilder


Posted Date: 09 May 2008      Total Responses: 4

Posted By: Musturu Thippa Reddy       Member Level: Silver     Points: 1


What is the use of command builder?



Responses

Author: shakti singh tanwar    09 May 2008Member Level: DiamondRating:     Points: 2
Command builder is used to automatically generate insert,update and delete commands from a data adapter that has a select command associated with it.

e.g

SqlConnection con = new SqlConnection("ConnectionString");
SqlCommand cmd = new SqlCommand("Select * from table",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "table");
//make changes in dataset

SqlCommandBuilder builder = new SqlCommandBuilder(da);
da.Update(ds, "table"); //Will update the data from dataset to database





Author: swathi.chilumula    10 May 2008Member Level: GoldRating:     Points: 2
Command Builder will configure DataAdapter vth Insert, Delete, and Update statement....

// For saving the Record into DB //

SqlCommandBuilder cb = new SqlCommandBuilder(da);
MessageBox.Show(cb.GetInsertCommand().CommandText);
da.InsertCommand = cb.GetInsertCommand();
da.Update(ds, "table");
MessageBox.Show("Record Saved");


Author: karthekeyan    11 May 2008Member Level: DiamondRating:     Points: 2
www.radsoftware.com.au/articles/usingcommandbuilder.aspx


Author: Sridhar R    16 Jul 2008Member Level: DiamondRating:     Points: 1
Command builder generates insert/update/delete commands for data adapter based on select command. Automatic creation of insert/update/delete commands hinders performance. In case if we know the contents of insert/update/delete, then we should create these explicitly. It is much better to create explicit stored procedures for insert/update/delete and assign these. Store procedures are much better way to do and it is all the way safer than these.

The command builder uses select command property of data adapter to determine values for other commands. If there is change in select command of data adapter, remember to call refresh Scheme to update the command properties. Point here to be note able is that command builder will only generate a command for data adapter’s command property if command property is null, if it is not null then it will not make.

By default command properties are null for data adapter, so whenever we use it we have to careful about it. If you explicitly set a command property, the command builder does not overwrite it. You need to set the command property to null to allow command builder to generate a command for command property. Another thing here is that command builder is nice to use and recommended if the tables are simple but when we are talking about complex select statements then we should give more parameters and new commands for each of the command properties in the data adapter.


Post Reply
You must Sign In to post a response.
Next : data view,datalist
Previous : div
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

conference call definitions

Contact Us    Privacy Policy    Terms Of Use