[英]VB.net which is better to use for query variable QUERY or should I use DA
Which is better to use for query 1 or 2 give me some tips. 给查询1或2更好的方法是给我一些提示。 I have a gridview that has a lot of info like hundreds.
我有一个GridView,其中包含许多信息,例如数百个。 Which is advisable to use for fast querying the result without lagging
最好将其用于快速查询结果而不会滞后
QUERY = "SELECT * FROM exdb.sample"
OR 要么
DA = New MySqlDataAdapter("SELECT * FROM exdb.sample", dataCNN)
If I am right you are talking about Connected and Disconnected Architecture, 如果我是对的,那么您在谈论的是“连接和断开连接的体系结构”,
Connected Architecture : you have to declare the connection explicitly by using Open(), and close the connection using Close(), and u cn execute commands using different methods like.. ExecuteNonQuery,ExecuteScalar,ExecuteReader etc.. 连接的体系结构:您必须使用Open()显式声明连接,并使用Close()关闭连接,然后使用不同的方法(例如ExecuteNonQuery,ExecuteScalar,ExecuteReader等)执行命令。
Disconnected Architecture: you dont need to define the connections explicitly..SqlDataAdatpter itself can open and closes the connection..and u can use dataset for storing the info. 断开连接的体系结构:您不需要显式定义连接。.SqlDataAdatpter本身可以打开和关闭连接。.您可以使用数据集来存储信息。 temporarily and Fill method was used to execute the commands give in adapter...
临时使用Fill方法执行适配器中给出的命令...
DataAdapter
, there's no requirement of opening and closing connection. DataAdapter
,不需要打开和关闭连接。 It's done automatically. But as you said there are hudreds of records in your application I'll suggest to use DataReader
(ie Connected Architecture
) as it is faster than DataAdapter
(ie Disconnected Architecture
) beacause it is read-only, forward-only stream of data. 但是正如您所说的,您的应用程序中有数百条记录,我建议您使用
DataReader
(即Connected Architecture
),因为它比DataAdapter
(即Disconnected Architecture
)要快,因为它是只读的,仅转发的数据流。 I'll suggest you go through this for more information about DataReader
and DataAdapter
. 我会建议你去通过此有关的更多信息
DataReader
和DataAdapter
。
First one is a connected architecture where you will loop through all the rows, populate them to a DataTable
and attach to your gridview. 第一个是连接的体系结构,您将在其中遍历所有行,将它们填充到
DataTable
并附加到gridview。
Whereas, second one is disconnected architecture using a data adapter; 第二个是使用数据适配器的断开连接的体系结构。 you maintain the structure in memory.
您在内存中维护结构。
I would go for the second approach, fill the dataset/datatable and bind the same source to gridview. 我将采用第二种方法,填充数据集/数据表并将相同的源绑定到gridview。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.