Typed DataSet

An XML schema can be used to generate a dataset that is “typed.” Instead of using the index property of a collection to access an element of the dataset, you can use the name of a column. Here is a fragment from the TypedDataSet example:

Dim UAL As AirlineBroker.AirlinesRow = _
   a.FindByName("United")
Console.WriteLine("{0}({1}) ReservationNumber:{2} " & _
   "WebSite:{3}", UAL.Name.Trim(), _
   UAL.Abbreviation.Trim(), _
   UAL.ReservationNumber.Trim(), UAL.WebSite.Trim())

You can assign a meaningful name to rows as well as use strong typing to make sure you are working with the data element you want. If you try to set the field UAL.ReservationNumber to an integer, the compiler will detect the mistake.

A typed DataSet inherits from the ...

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.