In ADO. net, there are five built-in objects: connection, command, datareader, dataadapter, and dataset.
ADO. NET is mainly divided into: DataSet and. Net frameword data provisionProgram.
Three methods of the command object: executenonquery (), executereader (), executescalar ();
Executenonquery () This method is used to execute add (insert), delete (delete), modify (update) data, and return the number of rows affected by SQL statements. When set nocount on is encountered in the stored procedure, the default value is returned. When a trigger is found in the table, the returned results are different from the actual results.
Executereader () This method is used to read data in a table. It is only forward and fast (relative to dataadapter ).
Executescalar () This method is used to read the values in the first column of the First row returned by the SELECT statement. The returned value is of the object type. Consider data type conversion.
The fill () method of the dataadapter object is used to fill in the data in the dataset. The update () method can update the modified data in the dataset to the database. Before calling Update (), specify dbcommandbuilder to automatically generate the insertcommand, updatecommand, and deletecommand attributes of the dataadapter object. Note one thing before generating these command objects, that is, when new data is added to the dataset, insertcommand is generated. Otherwise, this object is not generated. When the data in the dataset is changed, the updatecommand is generated. If no modification result is returned, the object is not generated. When the data in the dataset is deleted, the deletecommand is generated, this object is not generated if no data is deleted. When no data in the dataset is changed, the value returned by calling Update () is 0. If you modify the value, several rows of records are returned.
These five built-in objects are mandatory for. NET database operations.