Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (connection.State != ConnectionState.Open)
- {
- connection.Open();
- }
- using(SqlConnection connection = new SqlConnection(...))
- {
- connection.Open();
- // ... do your stuff here
- } // Connection is disposed and closed here, even if an exception is thrown
Add Comment
Please, Sign In to add comment