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

后端 未结 6 840
攒了一身酷
攒了一身酷 2021-02-13 02:06

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:23

    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().

提交回复
热议问题