且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何读取数据库列中的所有数据

更新时间:2023-02-10 13:48:09

正确的方法是,首先,仅读取所需的数据,其次,让数据库做它的工作.因此,您应该运行SQL,询问该列是否包含所需的值,而不是获取所有数据并在代码中进行字符串比较.
The correct way to do it is, first, only read the data you need and second, let the DB do it''s job. So, you should run SQL that asks if the column contains the value you want, not grab all the data and do string comparisons in code.


假设您必须在数据库中拥有信息, 这.循环播放不是一个坏选择.
将其添加到某个集合中而不是使用datagridview会更好-因为我猜您真的不希望看到数据?
我猜你将要流式传输文件,并通过datagridview查找匹配项?如果您有许多sig或许多文件,那将非常慢,因此您想尽可能地提高效率.

因此-将sig威胁和名称存储在某个列表中,例如List(of VirusDefinition)
然后您可以迭代该列表...
Assuming you have to have the info in your db, the. Looping as you are is not a bad option.
Adding to some collection rather than a datagridview would be better - as I''m guessing you don''t really want to see the data?
I''m guessing you''re going to stream in a file and the look through your datagridview looking for matches? That''s going to be pretty slow if you have many sigs or many files, so you want to be as efficient as should can.

So - store the sig threat and name in some collection like a List(of VirusDefinition)
Then you can iterate that list...
For each vid as VirusDefinition in myVirusDefinitions
If myTextFileInAString.Contains(vid.Sig) Then
    Do whatever you want to do
End if
Next