在VB.net中出现ExecuteReader 要求已打开且可用的 Connection.连接的当前状态为已关闭.
PublicFunctiongetall2dr(ByValstrWhereAsString)AsSqlClient.SqlDataReaderDimconnAsNewSq...
Public Function getall2dr(ByVal strWhere As String) As SqlClient.SqlDataReader
Dim conn As New SqlClient.SqlConnection
conn.ConnectionString = mycomm.SerConn.getSerConn
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = conn
cmd.CommandType = CommandType.Text
If strWhere <> "" Then
cmd.CommandText = "select * from GGUser where" & strWhere
Else
cmd.CommandText = "select * from GGUser"
End If
Dim dr As SqlClient.SqlDataReader
conn.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return dr
End Function
在VB.net中出现 dr = cmd.ExecuteReader(CommandBehavior.CloseConnection),ExecuteReader 要求已打开且可用的 Connection.连接的当前状态为已关闭. 展开
Dim conn As New SqlClient.SqlConnection
conn.ConnectionString = mycomm.SerConn.getSerConn
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = conn
cmd.CommandType = CommandType.Text
If strWhere <> "" Then
cmd.CommandText = "select * from GGUser where" & strWhere
Else
cmd.CommandText = "select * from GGUser"
End If
Dim dr As SqlClient.SqlDataReader
conn.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return dr
End Function
在VB.net中出现 dr = cmd.ExecuteReader(CommandBehavior.CloseConnection),ExecuteReader 要求已打开且可用的 Connection.连接的当前状态为已关闭. 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询