You don't want to. The SqlConnection
object is built to be created, inside of a using
as a best practice, used, and then disposed (hence the using
statement). Do not share connection objects. The operation of pooling connections to ensure that it's not expensive is handled by the server.
Per MSDN:
To ensure that connections are always closed, open the connection inside of a using block, as shown in the following code fragment. Doing so ensures that the connection is automatically closed when the code exits the block.
Do make sure you're setting the Pooling
property on the connection string to true
so that pooling is enabled; that would defeat the purpose otherwise (in general).