You want to call a stored procedure in ADO.NET that updates multiple records in a database. What is the recommended approach for handling the output and any potential errors?

  • Use SqlCommand.ExecuteNonQuery method to execute the stored procedure. Check for any errors using try-catch block and handle the output as needed.
  • Use SqlCommand.ExecuteReader method to execute the stored procedure and handle any output or errors using SqlDataReader.
  • Use SqlConnection to execute the stored procedure and handle output using SqlDataReader.
  • Use SqlDataAdapter to execute the stored procedure and handle output using DataSet.
SqlCommand.ExecuteNonQuery method is the recommended approach. It executes the SQL statement against the connection and returns the number of rows affected. Errors can be caught using a try-catch block. SqlDataReader is used for reading a forward-only stream of rows.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *