OleDbDataReader能否作为函数的返回值
Dim rd As OleDb.OleDbDataReader = OutLine.DisplayAllOutline("AUTO_CODE", True)
‘这一句调用下面的函数时,说OleDbDataReader已关闭,本人菜鸟,不明白是怎么回事,rd要先打开?
Public Shared Function DisplayAllOutline(ByRef sub_str_OrderByColume As String, Optional ByRef sub_IsReversed As Boolean = False) As OleDb.OleDbDataReader
Dim str_sql As New System.Text.StringBuilder
str_sql.Append("SELECT * FROM OUTLINE ORDER BY ")
str_sql.Append(sub_str_OrderByColume)
If sub_IsReversed = True Then
str_sql.Append(" DESC")
End If
Try
Using conn As New OleDb.OleDbConnection(g_str_DbConStr)
conn.Open()
Using comm As New OleDb.OleDbCommand
comm.Connection = conn
comm.CommandText = str_sql.ToString
Dim read As OleDb.OleDbDataReader = comm.ExecuteReader
Return read
End Using
End Using
Catch ex2 As Exception
MsgBox(ex2.ToString())
End Try
'Dim read As OleDb.OleDbDataReader = DbManager.GetResult(str_sql.ToString)
'Return read
End Function