Microsoft
98-361 · Question #331
98-361 Question #331: Real Exam Question with Answer & Explanation
Sign in or unlock 98-361 to reveal the answer and full explanation for question #331. The question stem and answer options stay visible for context.
Question
You have written a C# method that opens a database connection by using the SqlConnect object. The method retrieves some information from the database and then closes the connection. You need to make sure that your code fails gracefully when there is a database error. To handle this situation, you wrap the database code in a try-catch-finally block. You use two catch blocks--one to catch the exceptions of type SqlException and the second to catch the exception of type Exception. Which of the following places should be the best choice for closing the SqlConnection object?
Options
- AInside the try block, before the first catch block
- BInside the catch block that catches SqlException objects
- CInside the catch block that catches Exception objects
- DInside the finally block
Unlock 98-361 to see the answer
You've previewed enough free 98-361 questions. Unlock 98-361 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.