Click here to Skip to main content
15,890,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I want to load 25000 records from Sql server to Gridview in VB.NET Aplication.
The query is very fast but when I bind to Gridview, it takes 30 seconds.
Please help me how to solve this problem.
I saw other applications using Foxpro 8 (old DBF) can load 25,000 data to gridview less than 2 seconds.

Don;t ask why I want to load thousands of data at once, etc, etc.. i just need it. Please give me technical solution of this. Thanks all...

Regards
Henry

What I have tried:

Already try databind from datatable and already try add datagridrow manually.
Both not working.
Posted
Updated 10-Apr-16 5:36am
Comments
Ivan_FM 9-Apr-16 13:52pm    
How you poppulate the datagrid? can you give us some code?
Arvind Zamakia 9-Apr-16 23:07pm    
You can used stored procedure. Get data from page size data.for get row index to fetched data. Mins used custom paging.
Sergey Alexandrovich Kryukov 10-Apr-16 3:42am    
What exactly do you mean by "data grid"? How about full type name?
—SA

Not all DataGrids work the same. What you saw in FoxPro does not work the same as a control that displays a table in VB.NET. The DataGrid and DataGridView controls work differently and do more than the FoxPro grid does.

You really can't have the grids show 25,000 records without a performance hit. You absolutely need to implement paging. Load 50 records and bind to the grid. You can either have a background thread keep loading more and more pages as time goes on or you can just load the additional records when the grid is scrolled.

Google for "VB.NET DataGridView just in time loading" for more discussions and examples on it.
 
Share this answer
 
Comments
Member 8134723 10-Apr-16 15:39pm    
Hi,
Sorry, not very good in English..
I need to load around 25,000 rows to datagridview in VB.net at once, and then one of function I have to develop is like text search in Excel. I press Ctrl-F and entry the text and it will search from the datagridview.
Dont want to use paging or any connection to DB after first load.
Whenever you bind that much data to the page it is going to be slow, there is nothing you can do about that. There are better alternatives but you don't seem interested in them so you're just going to have to put up with slow performance.
 
Share this answer
 
Hi ,
i know you said "why do you want to load 25000" rows.But that is fundamental! and some of the native control (.net) might not be ideal.

however ,I didnt try but you could load in chunks using async.
Will the user be able to visualize 25000 rows at once?
if not you could do all sorts of pagination etc...

sorry but your explantion is a bit vague.

Returning 25000 rows in sql is very very fast if query done right.But not all controls are capable of doing that.

I know my answer does not help you but may be you could rework your question.
Anyway the datatable is the slowest you could possible use. you have to bind to an object
 
Share this answer
 
Comments
Member 8134723 10-Apr-16 15:38pm    
Hi,
Sorry, not very good in English..
I need to load around 25,000 rows to datagridview in VB.net at once, and then one of function I have to develop is like text search in Excel. I press Ctrl-F and entry the text and it will search from the datagridview.
Dont want to use paging or any connection to DB after first load.
I'm using a DataGridView from a third party .NET UI components company who abbreviate their name with "DX". One of the 2-3 best known companies in that market. You should find it by googling ".net ui components". For fun I tested it with a ~50,000 rows, ~30 columns DataTable and it displayed it almost instantly (on my i7-2600 desktop PC). Obviously it's not for free though.
 
Share this answer
 
Comments
Member 8134723 10-Apr-16 15:40pm    
Thanks, this is interesting
I've tried this, and seems so much faster if you populate the DataGridView from a Dataview instead of a Datatable. Also this allows options to sort and filter the results that are a lot faster.

Check it out: Creating a DataView[^]
 
Share this answer
 
Comments
Member 8134723 10-Apr-16 15:42pm    
thank you. Will check it..
Probably there are many datagridview events are firing while binding the drid with datasource. Try to RemoveHandler and AddHandler after the grid is bound.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900