c # basis of the DataSet and DataTable

(. 1) the DataSet data set, the DataTable data table, DataSet stores a plurality DataTable. DataSet and DataTable like a special container to store data, which can be present when you query the database to get some results. DataReader fast data processing speed, but it is read only once to the next line can not view the data on line, the DataSet can freely move the pointer. DataSet data is disconnected from the database. DataSet can also be used in multi-layer application, if the application is running in the intermediate layer in the business object to access the database, the service objects for an offline data structure is passed to the client application.

(2) create a function

DataTable () to initialize a new instance of the parameter without DataTable class. 
DataTable (string tableName) a new instance of the specified table name DataTable class initialization. 
DataTable (string tableName, string tableNamespace) to initialize a new instance of the class with the specified DataTable table name and namespace. 

(3) SqlDataAdapter is a bridge between the DataSet and SQL Server, and for retrieving stored data. SqlDataAdapter by using an appropriate mapping Fill Transact-SQL statements to the data source (which can be changed to match the data in the DataSet data source), and Update (it can change the data in the data source to match the data in the DataSet) to provide this bridge. When filling SqlDataAdapter DataSet, it creates the necessary tables and columns (if they do not already exist tables and columns) for the returned data.

If you only need to perform SQL statement or SP, there is no need to use DataAdapter, you can directly use SqlCommand the Execute method of the series. sqlDataadapter role is to achieve a bridge between DB and Dataset: for example, will modify the DataSet to update a database .

Since the DataSet is off-line processing, so when you want to lock in a transaction database, can not use DataSet. Because When DataSet is filled, automatically disconnects from the database, the database at this time no longer locked.

SqlDataAdapter UpdateCommand of enforcement mechanisms are: when calling SqlDataAdapter.Update (), check all rows in the DataSet, and then perform SqlDataAdapter.UpdateCommand for each modified Row, that is to say if the unmodified data in the DataSet, SqlDataAdapter. UpdateCommand not be executed.

(4)

 

Guess you like

Origin www.cnblogs.com/anjingdian/p/11073802.html