开发者

vb net mysql reader progress

hey guys, i wanna know if its possible to find out in a reader how much reading is left to do. My code will be below and i think it be fairly possible during a query that would be returning data but is it possible during a query designed to give data?

Public Function queryup(ByVal queryString As String, ByVal connection As MySqlConnection)
    Try
        Dim newQuery As String() = Split(queryString, ":")
        For Each Query In newQuery
            Dim cmd As New MySqlCommand(Query, connection)
            Dim reader As MySqlDataReader
            reader = cmd.ExecuteReader()
            While reader.Read()
            End While
            reader.Close()
        Next
    Catch ex As Exception
        console("Error 开发者_运维百科with MySQL: " & ex.Message)
        Return ex.Message
    End Try
    Return ""
End Function

that was the send data query, this is the receive data query.

Public Function querydown(ByVal queryString As String, ByVal connection As MySqlConnection)
    Dim returnInfo As New StringBuilder
    Try
        Dim newQuery As String() = Split(queryString, ":")
        For Each Query In newQuery
            Dim cmd As New MySqlCommand(Query, connection)
            Dim reader As MySqlDataReader
            reader = cmd.ExecuteReader()

            While reader.Read()
                For a = 0 To reader.FieldCount - 1
                    Dim strng As String = reader.GetString(a)
                    returnInfo.Append(strng & ",")
                Next

                returnInfo.Append(";")
            End While
            reader.Close()
        Next
    Catch ex As Exception
        console("Error with MySQL: " & ex.Message)
        Return ex.Message
    End Try
    Return returnInfo.ToString
End Function
enter code here


From what I understand, DataReader does not have a recordcount property, so your primary question of how much is left cannot be answered with the data reader. Can you use a data table and use its rows.count property instead?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜