Difference between SqlCommand and SqlCommandBuilder

Questions by ateeqpasha

Editorial / Best Answer

sahu  

  • Member Since Dec-2005 | Mar 29th, 2007


Hi All,

Ans:

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.



Showing Answers 1 - 2 of 2 Answers

Pankaj Naval

  • Jun 8th, 2006
 

SQLCommand is used to retrieve or update the data from database.

You can use the SELECT / INSERT,UPDATE,DELETE command with SQLCommand. SQLCommand will execute these commnds in the database.

SQLBUILDER is used to build the SQL Command like SELECT/ INSERTR, UPDATE etc.

  Was this answer useful?  Yes

SuryaNarayanan Sk

  • Jun 12th, 2006
 

Using Sqlcommand   we can Execute    select,update,delete ..... Querys

Using SqlCommandBulider we can  generate Select ,update,delete Querys

 

  Was this answer useful?  Yes

Mob: +91 9849255958

  • Jan 4th, 2007
 

SqlCommand  is used to execute any sql statement, where as

SqlCommandBuilder generates sql commands like INSERT, UPDATE, and DELETE based on the columns in the SELECT statement.

  Was this answer useful?  Yes

SQLCommandBuilder object is used to build & execute SQL (DML) queries like select, insert, update & delete.

Whereas

SQLCommand  is used to execute all kind of SQL queries like DML & DDL.

  Was this answer useful?  Yes

Hi All,

Ans:

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.



Goblet

  • Aug 31st, 2009
 

SqlCommandBuilder is used to generate sql statements in order to update a dataset with more efficiently.
We have just to specify the table when you use the Fill method

Example :
       
Dim builder As SqlCommandBuilder = New SqlCommandBuilder(adapter)

adapter.Fill(dataSet, tableName)


//doesn't work if you don't specify previously  the SQLCommandBuilder
adapter.Update(dataSet, tableName)


  Was this answer useful?  Yes

abhi_la2006

  • Sep 20th, 2010
 

SQL command excute and handle both DML(Insert, Update, Delete) and DDL (Drop Create Table db) While sqlcommandbuilder excute only DML queries.

  Was this answer useful?  Yes

abhi_la2006

  • Jul 13th, 2011
 

Sql command use to only execute dml like update delete insert but sql command builder use the dml as well as the ddl like create database alter etc.

  Was this answer useful?  Yes

Lijo

  • Nov 10th, 2011
 

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. When an instance of the SqlCommandBuilder class is created, it automatically generates Transact-SQL statements for the single table updates that occur. The object of the SqlCommandBuilder acts as a listener for RowUpdating events, whenever the DataAdapter property is set.

Code
  1. DataSet ds = new DataSet();

  2. SqlConnection cn = new SqlConnection("strSomeConnectionString");

  3. //Autogenerate Insert, Update & Delete commands

  4. SqlDataAdapter da = new SqlDataAdapter("Select from t_Something", cn);

  5. SqlCommandBuilder scb = new SqlCommand(da);

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions