I was looking for a way to extract data from a SqlDataSource object within VB.NET code but looking at the code I found for this leads me to believe that the select statement is executed once again during the DirectCast.
Does anyone know if this usage causes an additional select statement to be run even though the SqlDataSource has already run previously?
The post I got this from is here: How can i iterate through row of particular table associated with SqlDataSource control in VS 2008?
Here is the code:
Dim datareader = DirectCast(SqlDataSource2.[Select](DataSourceSelectArguments.Empty), SqlDataReader)
While datareader.Read()
Label2.Text = datareader("LastName").ToString()
End While
datareader.Close()
A data reader will read from the source.
If the source is a database, then the reader will read from the database every time you call
Read().It is unclear to me what your DirectCast is there for or why you are using it.