If an SqlCommand is executed and times out, is the respective SqlConnection closed and/or disposed?
If an SqlCommand is executed and times out, is the respective SqlConnection closed and/or
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unless you have your SqlConnection wrapping in a
usingstatement, you’re still responsible for closing and disposing the connection (just like any other exception).You could also use a
try/catch/finallyblock:But
usingis much cleaner and disposes automatically: