The executescalar method returns the object type. This method returns the value in the first column of the First row after the SQL statement is executed. The structure of the SQL statement is unknown (it may be int, it may be char, etc.), so the executescalar method returns the most basic type object, which is the base class of all types. In other words, it can be converted to any type.
The executenonquery method is used to execute insert, delete, and update statements. Because these statements have only one result after execution: "affected ** rows ", therefore, the executenonquery method returns the number of affected rows (INT ).
Although the name of a column in SQL is of the string type, you must forcibly convert the type to access this field using datareader ["name, because datareader ["name"] is like an array, the types of each element in the array should be the same, so the element type in the array datareader [] is also defined as the object type, to facilitate conversion.