.net SqlConnection not being closed even when within a using { }

后端 未结 6 1300

Please help!

Background info

I have a WPF application which accesses a SQL Server 2005 database. The database is running locally on the machine the appl

6条回答
  •  礼貌的吻别
    2021-02-13 02:26

    The Dispose should close the connections, as MSDN points out:

    If the SqlConnection goes out of scope, it won't be closed. Therefore, you must explicitly close the connection by calling Close or Dispose. Close and Dispose are functionally equivalent. If the connection pooling value Pooling is set to true or yes, the underlying connection is returned back to the connection pool. On the other hand, if Pooling is set to false or no, the underlying connection to the server is closed.

    My guess would be that your problem has something to do with GetContext().

提交回复
热议问题