What is the difference SqlCommand and SqlDataAdapter

 

 

Because the DataSet is offline, so the SqlDataAdapter object as a bridge between the DataSet and the database, all operations (filling, update, etc.) on the DataSet go through him

ado.net data access in two ways:

1. Offline - through the DataSet, then offline add, delete, change, and finally to the database by parsing SqlDataAdapter

2. Direct database operations SqlCommand (Update, Insert, Delete)

SqlCommand that is a command, you can use it to execute SQL commands

SqlDataAdapter is a data adapter, which is used in the data source and data sets a communication between the set of objects

SqlCommand correspond DateReader

The corresponding DataSet SqlDataAdapter

SqlCommand object in C # dealing with Sql Database, Sql almost all database operations need to use the object to achieve, but limited in its capabilities, it simply implements the interface Sql database;

SqlDataAdapter is a powerful SqL data adapter, also for operating Sql database, but its operation should be achieved through SqlCommand (there is a property of an object type is SqlCommand), that is, can be seen as a SqlDataAdapter the Some special features package, and enhances the SqlCommand!

SqlCommand and Command ADO era, like, SqlDataAdapter is ADO.NET new things, which is used with the DataSet. In fact, DataSet is like a small database that resides in memory, can have multiple sheets in the DataSet DataTable, can be correlated between DataTable, just as in the related tables in the database! SqlDataAdapter role is to extract data from the database and put the DataSet, when the data changes in the DataSet, SqlDataAdapter then the database data updates to ensure that the data in the database and the DataSet data is consistent!

Microsoft consultant with the words: DataAdapter is like a spade, shovel which is responsible for the data from the database into a DataSet, or shovel the data from the DataSet to the database!

Guess you like

Origin www.cnblogs.com/wfy680/p/12004527.html