Why call SqlClient.SqlDataReader Close() method anyway?

前端 未结 8 869
执笔经年
执笔经年 2020-12-15 06:48

Is the SqlClient.SqlDataReader a .NET managed object or not? Why do we have to call the Close() method explicitly close an open connection? Shouldn\'t running out of scope f

8条回答
  •  温柔的废话
    2020-12-15 07:24

    It's not the Connection that's the problem, but the SQL Cursor being held by the SqlDataReader. If you try to open a second without closing the first, it will throw an exception.

提交回复
热议问题