DataSet Fundamentals

You can also fetch a subset of the data in the DataSet. The Select method on a DataTable uses the same syntax as a SQL statement where clause. Column names are used to access the data for a particular row. This example comes for the HotelBroker class, where it is used to get the hotels for a particular city.

 Public Function GetHotels(ByVal city As String) _ As ArrayList Implements IHotelInfo.GetHotels ... Dim t As DataTable = hotelsDataset.Tables("Hotels") Dim rows() As DataRow = t.Select( _ "City = '" & city & "'") Dim hl As HotelListItem Dim hotels As New ArrayList() Dim i As Integer For i = 0 To rows.Length - 1 hl.HotelName = rows(i)("HotelName").ToString().Trim() hl.City = rows(i)("City").ToString().Trim() hl.NumberRooms ...

Get Application Development Using Visual Basic® and .NET 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.