哪个是从VB.NET中的SQL Server 2008中检索数据的最快方法? [英] Which is the Fastest Way to Retrieve Data From SQL Server 2008 in VB.NET ?
问题描述
您好!
我面临的问题是我在vb.net 2010中使用后端SQL Server 2008开发的项目。此应用程序在网络上运行。部署SQL Server 2008数据库在服务器系统上,该网络上超过25个客户端同时访问数据库。
虽然一切都很好,但问题是当检索到大量数据时(更多)然后速度非常慢。
任何人都可以帮我这个???
以下是我使用的代码。
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"
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()
推荐答案
不要一次读取太多数据,在块中读取它,只显示用户需要查看的信息。您还可以使用DataAdapter,并在后台运行查询以帮助减少可见的延迟。
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.
除了我将建议的解决方案1之外,您可能会发现这一点CP文章有用在SQL中优化数据访问的十大步骤服务器:第二部分(重新考虑TSQL并应用最佳实践) [ ^ ]
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)[^]
这篇关于哪个是从VB.NET中的SQL Server 2008中检索数据的最快方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!