我的类中有函数,它获取查询字符串并返回二维对象数组:
Public Function GetResultsBySql(ByVal sql As String) As Object(,)
Dim b(,) As Object = Nothing
Dim Command As New MySqlCommand(sql)
Dim rowCount As Int32 = -1
Using Conn As New MySqlConnection(Me.ConnectionString)
Command.Connection = Conn
Command.CommandTimeout = TimeOut
Try
Conn.Open()
Dim Dr As MySqlDataReader = Command.ExecuteReader
Do While Dr.Read
rowCount += 1
ReDim Preserve b(Dr.FieldCount - 1, rowCount)
For j As Int16 = 0 To Dr.FieldCount - 1
b(j, rowCount) = Dr(j)
Next
Loop
Return b
Catch ex As Exception
MsgBox(ex.Message.ToString, , "GetResultsBySql")
Return Nothing
End Try
End Using ' Connection
End Function
当我提供最初返回156000条记录的查询时。 (在toad for mysql中),对象数组只包含71875条记录。 这是由于DataReader限制还是由于操作内存泄漏?没有异常被抛出。
任何想法?