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.
精彩评论