Dataset contains the tables array of the datatable type.
Each datatable also contains the rows set of the datarow type, including the columns set of the datacolumn type.
Datatable = dataset. Tables [0];
Datarow = dataset. Tables [0]. Rows [0];
Get column value:
Object columnvalue = dataset. Tables [0]. Rows [0] [0];
// -- = ---------------------------------------------- = ---
Changes in datarowversion:
After the beginedit method of datarow is called, the current and proposed values are available.
After the canceledit method of datarow is called, the proposed value is deleted.
After the endedit method of datarow is called, the value of proposed becomes the current value.
After datarow's acceptchanges is called, the original value is changed to the current value.
After datarow's rejectchanges is called, the proposed value is discarded and the version is changed to current.
After the datatable acceptchanges is called, the original value is changed to the current value.
// -- = ---------------------------------------------- = ---
Method of data adapter dataadapter:
1. Fill: load data from the data source to the dataset.
2. Update: load data from the dataset to the data source.
// -- = ---------------------------------------------- = ---
Fill Method:
1. Fill (Dataset)
2. Fill (datatable)
3. Fill (dataset, tablename );
4. Fill (datatable, datareader): Fill the data table with the specified datareader
★By default, when calling the fill method of dataadapter, in addition to filling in dataset, dataset is also automatically called. in acceptchanges, the status of all rows after the call is not "changed". At this time, the values of original and current are the same.
★If you want to fill in one dataset from multiple data sources and write it back to another data storage, set the acceptchangesduringfill attribute of dataadapter to false so that the result row can be expressed as a newly added row.
Update method:
1. Update (Dataset): update the data source based on the data table in the specified dataset.
2. Update (datatable): update the data source based on the specified data table
3. Update (datarows): update the data source based on the specified array of data rows.
When the update method is called, dataadapter analyzes the changes and runs the corresponding commands (insert, update, delete ). when the dataadapter encounters a datarow change, it uses insertcommand, updatecommand, and deletecommand to handle the change. in this way, you can try to improve the ado.net application by developing command syntax at design and using stored procedures whenever possible. Program Before calling the update command, make sure that the three commands used to change data exist. Otherwise, an exception is thrown.
// -- ===---------------------------------------------- ==---
data adapter event
1. onrowupdating: Run
2. onrowupdated: this parameter is executed after the data row is updated. You can check the execution results of a single update.
the eventargs Attribute Table is as follows
database command to be executed by command
errors error
row to be updated
statementtype indicates the command type to be executed, it may be one of the add, delete, modify, and query rows to be affected by
recordsaffected
datatablemapping used for tablemapping update