ExecuteReader requires an open and available Connection. The connection's current state is closed

≯℡__Kan透↙ 提交于 2019-12-01 16:25:21

I think you have forgotten to open the connection.

Open it before this line:

cmd.Parameters.AddWithValue("@baskethash", baskethash)

Using -

db.Open()

You actually forgot to Open connection:

        db.Open()
        Using dr As SqlDataReader = cmd.ExecuteReader()

One reason for this would be that your connection could not be opening at all. What ever exception that is coming at the "SqlConnection.Open" statement is being suppressed. If the problem is not in your application it could be that server is unable to grant you a connection. Could be because of a connection leak in your app or in some other database hosted on the same server.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!