Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SqlConnection connection = new SqlConnection(FROM_CONFIGURATION)
- SqlCommand command = new SqlCommand("SomeSQL", connection);
- connection.Open();
- command.ExecuteNonQuery();
- command.Dispose();
- connection.Dispose();
- class MonkeyGrabber : IDisposable {
- public MonkeyGrabber() { /* construction grabs a real, live monkey from the cage */
- public void Dispose() { Dispose(true); /* releases the monkey back into the cage */ }
- // the rest of the monkey grabbing is left as an exercise to grad student drones
- }
- class MonkeyMonitor {
- public void CheckMonkeys() {
- if (_monkeyPool.GettingTooRowdy()) {
- MonkeyGrabber grabber = new MonkeyGrabber();
- grabber.Spank();
- }
- }
- }
- using (SqlConnection connection = new SqlConnection(...))
- using (SqlCommand command = connection.CreateCommand())
- {
- ...
- }
- using (SqlConnection connection = new SqlConnection(FROM_CONFIGURATION))
- using (SqlCommand command = new SqlCommand("SomeSQL", connection))
- {
- connection.Open();
- command.ExecuteNonQuery();
- command.Dispose();
- connection.Dispose();
- }
Add Comment
Please, Sign In to add comment