开发者

How would you know if "DataTable.Load()" finished loading?

开发者 https://www.devze.com 2023-04-05 01:53 出处:网络
How would you know if all result data are loaded in the DataTable when you use DataTable.Load? Or rather, how would we know if the DataReader has finished loading the data?

How would you know if all result data are loaded in the DataTable when you use DataTable.Load? Or rather, how would we know if the DataReader has finished loading the data?

Code:

'Connection, command etc.
Dim Reader as SqlDataReader = Command.ExecuteReader()
Dim SomeDataTable as new DataTable()
SomeDataTable.load(Reader); 'When will loading be finished or how would you know?

I'm using VB.NET

Update:

Here's my original code:

Private Function LoadPRS(ByVal Username As String) As DataTable
    Dim PRSList As New DataTable

    Using Connection As New SqlConnection(ConfigurationManager.ConnectionStrings("DBCS").ToString)
        Using Command As New SqlCommand _
            ("select * from products", Connection)

            Connection.Open()
            Using Reader = Command.ExecuteReader
                P开发者_如何学运维RSList.Load(Reader)
            End Using
        End Using
    End Using

    Return PRSList
End Function


To the best of my knowledge, that method is synchronous. You know it has finished because the method returns to you. If it didn't "finish", it would have thrown an exception.

0

精彩评论

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