Turn:
because the dataset is offline, the SqlDataAdapter object is a bridge between the dataset and the database, and all operations on the dataset (fill, update, etc.) are passed through hisThere are two ways to access ADO data:1. Offline-through a dataset, then offline Add, delete, change, and finally through the SqlDataAdapter resolution to the database2. Direct database Operation SqlCommand (Update,insert,delete)
SqlCommand is an order, you can use it to execute SQL commands
SqlDataAdapter is a data adapter, which is a set of objects used to communicate between a data source and a dataset SqlCommand corresponding Datereader
SqlDataAdapter corresponding DataSet SqlCommand is a C # object dealing with SQL database, almost all SQL database operations need to use this object to implement, but its function is limited, but simply to implement the interface with SQL database;
SqlDataAdapter is a powerful SQL data adapter and is also used to manipulate SQL databases, but its operations are implemented through SqlCommand (the type of a Property object is SqlCommand), which means You can think of SqlDataAdapter as a sqlcommand! that encapsulates and enhances a few special functions. SqlCommand and the command of the ADO era, SqlDataAdapter is a new thing in ADO, which works with datasets. In fact, a dataset is like a small database that resides in memory, and there can be more than one DataTable in a dataset that can be associated with one another, just like a table in a database! SqlDataAdapter's role is to extract data from the database and put it in a dataset, and when the data in the dataset changes, SqlDataAdapter updates the data in the database. To ensure that the data in the database is consistent with the data in the DataSet!
In the words of Microsoft Consultant: DataAdapter is like a spade, it is responsible for the data from the database "shovel" into the dataset, or the data from the dataset "shovel" into the database!
-----------------------------------------
SqlDataReader can only be read sequentially, can not modify the database before the program is not finished to keep the connection SqlDataAdapter once read out, you could put in the dataset. Can be used to modify the database
What's the difference between SqlCommand and SqlDataAdapter?