Click here to Skip to main content
15,891,375 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 vb.net 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 =192.168.1.200; Database=DBName; User ID=sa; Password=password; Connect Timeout=0"

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

SQL_CONNECTION.Close()
Posted
Updated 10-Jan-15 3:00am
v3

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
 
v2
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