Click here to Skip to main content
15,664,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello !
i am facing a problem with my project which i developed in 2010 with back end SQL Server 2008. this application is running on a network. Database of SQL Server 2008 is deployed On a server system and more than 25 clients on this network access the database simultaneously.
although every thing is fine but the problem is that when a huge data is retrieved (more than 200 rows) to a datagridview then the speed is very slow.
can anyone help me for this ???
the following is the code which i use.
SQL_CONNECTION.ConnectionString = "Data Source =; Database=DBName; User ID=sa; Password=password; Connect Timeout=0"

MyQuery = "SELECT * From TableName"
MyCommand = New SqlCommand(MyQuery, SQL_CONNECTION)
                MyDataReader = MyCommand.ExecuteReader
                RowNo = 0
                GridName.RowCount = 0
                While MyDataReader.Read
                    GridName.Rows(RowNo).Cells(1).Value = MyDataReader!FieldName
               End While

Updated 10-Jan-15 3:00am

Don't read too much data at one time, read it in 'chunks' that display just the information that the user needs to see. You could also make use of a DataAdapter, and run the queries in the background to help reduce the visible delay.
Share this answer
Further to Solution 1 which I was also going to suggest, you may find this CP article useful Top 10 steps to optimize data access in SQL Server: Part II (Re-factor TSQL and apply best practices)[^]
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