Background populating DataGridView from SqlDataAdapter

I have a large dataset (over 100,000 records) that I want to load into a DataGridView. A stored procedure that does this can take 10 seconds or more.

So far, I have a BackgroundWorker that prevents user interface locking and has implemented a rudimentary "Please Wait" dialog.

What I would like to do is somehow populate the DataGridView with the results, as they are somehow coming back from the database. The best way to describe this — as SQL Server Management Studio does — when the query is executed, rows are returned immediately, even if the query is still running. There is also a button to stop the query and save the rows that were returned.

How can I do this in my own code?

A DataGridView is only used to display rows of data, and then the user clicks one to do something else. Nothing is returned to the database.

+3
source share
5 answers

100,000 rows in a datagridview? just say no!

  • user cannot see 100,000 rows at a time
  • network traffic to transmit 100,000 lines is not negligible.
  • the memory overhead for 100,000 rows of datagridview data is not negligible.
  • the user only needs to select one row and go
  • If this application is ever used by several users at the same time, DBA will prey on you.

follow austin recommendations and only display the page at a time

+4

, - , . . GridView ( .NET , , ). LINQ to SQL, . , , , .

http://www.dbtutorials.com/display/linq-to-sql-paging-cs.aspx

+4

, 100K , ...

, . , .

, , . - , . . , datareader - , - .

+2

, DataGridView , Management Studio. , , .

0

. . SQL Server Management Studio " ". , (.. ). , . , - . .

0

Source: https://habr.com/ru/post/1699384/


All Articles