To add to what Dave has - rightly said - what you are doing doesn't retrieve 1,000,000 records anyway - it tries to retrieve 2,000,000 instead!
sqlconn1.Open()
sqladaptor.SelectCommand = New SqlCommand("Select * from Profile, sqlconn1)
sqladaptor.SelectCommand.CommandTimeout = False
sqladaptor.SelectCommand.ExecuteNonQuery()
sqladaptor.Fill(dt)
sqlconn1.Close()
sqlconn1.Dispose()
sqladaptor.Dispose()
This line:
sqladaptor.SelectCommand.ExecuteNonQuery()
Executes your SQL Command, which means that SQL prepares 1,000,000 rows for return, and returns the number of rows it found.
Then this line:
sqladaptor.Fill(dt)
Does it again, storing all 1,000,000 rows into a DataTable.
If you had tried to find a less efficient way to do anything, that would probably be it!
And please, don't use
SELECT * FROM
- always list the rows you want in the order you want them:
SELECT Column1, Column2 FROM ...
that reduces the amount of data you want to fetch to the minimum by only returning columns you are going to use - and images for example can take considerable space - and makes your code my "robust" in the event of database changes.
But the primary thing to take away from this is as Dave says: never try to present more than a hundred or so rows to a user: page it, search it, filter it - but think like a user for a moment: how are you going to find the row you are interested in out of 1,000,000 rows slapped on your screen? How long will it take you to scroll down that far?
Do it your way, and you users will hate you app, and by extension you.