| 1. |
When Do You Use Executereader, Executenonquery, Executescalar Methods? |
|
Answer» If the command or STORED procedure that is being executed returns a SET of rows, then we use ExecuteReader method. If the command or stored procedure that is being executed returns a single value then we use ExecuteScalar method. If the command or stored procedure performs INSERT, DELETE or UPDATE operations, then we use ExecuteNonQuery method. ExecuteNon Query method returns an integer specifying the NUMBER of rows inserted, deleted or updated. If the command or stored procedure that is being executed returns a set of rows, then we use ExecuteReader method. If the command or stored procedure that is being executed returns a single value then we use ExecuteScalar method. If the command or stored procedure performs INSERT, DELETE or UPDATE operations, then we use ExecuteNonQuery method. ExecuteNon Query method returns an integer specifying the number of rows inserted, deleted or updated. |
|