Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any code to binding the datagridview faster in vb.net

VB
Try
         Dim conn As New OleDbConnection(CnString)
         conn.Open()
         Dim cmd As New OleDbCommand(Query, conn)
         Dim ada As New OleDbDataAdapter(cmd)
         Dim dt As DataTable = New DataTable
         ada.Fill(dt)
         grd.DataSource = Nothing
         grd.DataSource = dt
         grd.AutoGenerateColumns = False
         conn.Close()
     Catch ex As Exception

     End Try

I have used the code above for binding datagridview. Please help me if any other code exist
Posted

1 solution

Probably not, that code should be fine.

If it's slow, then the likely reason is that the query is the problem, and most likely that you are retrieving far too many rows, or the column data you are fetching includes a large data type (such as images).
The more rows your query returns, the slower it will be to load them into the DGV. Think about the user: if you are loading a lot of rows into the display, then speed is the least of the problems you are giving them - finding the information they are looking for becomes increasingly show, difficult, and frustrating as the row count increases. As a general rule, if you are showing more than 100 or so rows, that's too many, and you need to provide searching and filtering instead.

Have you checked how much data you are returning?
 
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