如何使用 Like 条件从数据集中获取特定数据到数据行?

How to use Like condition to get specific data from dataset to datarow?

我在 .Net MVC 4.0 中使用 VB.Net 语言

我有一个数据集,其中包含像

这样的记录
1 David   05/31/2011 05/16/2011

2 Rassell 06/15/2011 06/01/2011 

3 David   06/15/2011 06/01/2011

数据集中有数千条记录,我只想使用从数据集到数据行的类似条件获取 David 的数据。

我该怎么做?

这是您可以用来从数据集中过滤数据的代码。 根据您的数据 table.

替换变量 / table / 列名

您将得到一个数据行数组。如果您期望一行,则从结果中取出第一行,否则它将为您提供具有 "David" 作为人名的所有行。

Dim table As DataTable = DataSet1.Tables("Orders")

Dim expression As String
expression = "PersonName Like '%David%'" 

Dim foundRows() As DataRow
foundRows = table.Select(expression)