O'Reilly logo

Visual Basic® .NET Database Programming by Rod Stephens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning About Fields

If you know that a table exists in a database, learning about the fields it contains is relatively easy. The following sections describe several ways a program can obtain information about the table’s fields.

Filling a DataTable

One method to get information about a table’s fields is to use a data adapter to fill a DataTable with the results of the query SELECT * FROM table_name . The DataTable object’s Columns collection contains information about the table even if the query returns no records.

Example program TableColumns, shown in Figure 13.1, demonstrates this technique. The program uses the code in Listing 13.1 to display information about a table’s columns.

Figure 13.1. Program TableColumns uses a data adapter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required