Difference between Sqlcommand and Sqlcommand builder Class
Brief describe where we can use sqlcommand class and where sqlcommand builder because I think both class have the same work.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
RanjithKumar chiguruvadaPosted Sep 18, 2012, 10:07 AM
SqlCommand: SqlCommand is used to execute Query involving Select, Update, Delete operation and to Execute SQL Stored procedures
SqlCommandBuilder:SqlCommandBuilder provides the feature of reflecting the changes made to a DataSet or an instance of the SQL server data.The object of the SqlCommandBuilder acts as a listener for RowUpdating events, whenever the DataAdapter property is set.
a) SQLCommand is used to execute all kind of SQL queries like DML(Insert, update,Delete) & DDL like(Create table, drop table etc)
b)SQLCommandBuilder object is used to build & execute SQL (DML) queries like select, insert, update & delete.
SqlCommandBuilder example as follows,
DataSet ds = new DataSet();
SqlConnection cn = new SqlConnection("strSomeConnectionString");
//Autogenerate Insert, Update & Delete commands
SqlDataAdapter da = new SqlDataAdapter("Select from t_Something", cn);
SqlCommandBuilder scb = new SqlCommand(da);
Rewant ChoudharyPosted Sep 18, 2012, 9:33 AM
b)SQLCommandBuilder object is used to build & execute SQL (DML) queries like select, insert, update & delete.
Dorababu MekaPosted Sep 18, 2012, 8:32 AM
http://www.c-sharpcorner.com/forums/thread/150689/sqlcommandbuilder-class-in-ado-net.aspx