Differences between SqlCommand and SqlDataAdapter.

 Posted by Ddd on 1/20/2011 | Category: ADO.NET Interview questions | Views: 21004 | Points: 40

1) Represents a Transact-SQL statement or stored procedure to
execute against a SQL Server database.
2)It can be initalized by any T-SQL satement
3)we have to explicitly initalize SqlDataReader when we use SqlCommand
4)database connections have to be manually opened and closed.

1)Represents a set of data commands and a database connection that
are used to fill the DataSet/DataTable and update a SQL Server database.
2)It can be initialized using Select command either directly in its constructor
or by assigning an object of SqlCommand containing a select statement
to its SelectCommand property.

3)SqlDataReader is internally used in SqlDataAdapter.
4)database connections are automatically opened and closed.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Prabhakar on: 1/21/2011 | Points: 10
SqlDataAdapter acts as the bridge between database and dataset.. It just used to Fill the data from Database to Dataset. but SqlCommand used to execute Queries with Physical Database... and You can manipulate like insertion, deletion, updation with the database

Thanks & Regard's

Login to post response