我目前得到的錯誤:ExecuteReader需要一個開放且可用的Connection。連接的當前狀態是開放
ExecuteReader requires an open and available Connection. The connection's current state is open.
這裏是我的代碼:
班db.conn
Public Class db
Public Shared conn As SqlConnection = db.getsqlconn("ezondb")
Public Shared Function getsqlconn(ByVal whichdb As String) As SqlConnection
Dim connstring As String = ConfigurationManager.ConnectionStrings(whichdb).ConnectionString
Return New SqlConnection(connstring)
End Function
Dim Macomm = db.selectcommand(db.conn, "*", "categories", "idparentcategory=1")
Dim Mada As New SqlDataAdapter(Macomm)
Dim Mat As New DataTable
Mada.Fill(Mat)
請向我們展示更多代碼。你在哪裏打開連接? – 2013-04-20 14:11:25
我添加了更多代碼。 – 2013-04-20 14:13:27
在您顯示的連接未打開的代碼中。 – 2013-04-20 14:15:32