Harry,
I think because you are opening the connection to SQL server outside (before) of the try-catch block.
The best way is like:
using (SqlConnection connection = new SqlConnection(connectionString)) { try { connection.Open(); Execute a Get stored procedure to read data from a table } catch (SqlException) { log the exception } }Hope it helps!!
Please click "Mark As Answer" if my post helped.