Using the DataTable Class’s Searching and Filtering Features

The DataTable class exposes two methods that you can use to locate data based on search criteria. One method, Find, lets you locate a row based on its primary key values. The other, Select, acts as more of a filter, returning multiple rows of data based on more flexible search criteria.

Locating a Row by Its Primary Key Values

When you’re querying your database for information, you’ll often want to retrieve a specific row of data based on the values of its primary key columns, using a query such as this one:

SELECT CustomerID, CompanyName, ContactName, Phone
       FROM Customers WHERE CustomerID = 'ALFKI'

You can also locate a DataRow in a DataTable based on the row’s primary key values. You might ...

Get Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.