Closing SqlConnection Objects

Closing a SqlConnection object is even easier than opening one. Simply call the object’s Close method. If you use connection pooling, which We’ll discuss in detail later in the chapter, the physical connection to the database is pooled rather than closed and can be reused later. If you’re not using connection pooling, the physical connection to the database will be closed.

Calling the Close method on a SqlConnection object that is already closed will not cause an exception.

Get Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.