Do I need to use SqlConnection.Open()
inside:
using (SqlConnection var = new SqlConnection())
{
//my operations
}
?
What happens if I don't dispose this connection by SqlConnection.Close()
function?
Yes, you need to Open
your connection inside the using
block.
If you don't explicitly Close()
the connection, the end of the using
block will do it for you as the using disposes of the connection. When a connection is disposed it is automatically closed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With