asp.net.ph

DataTable.Columns Property

System.Data Namespace   DataTable Class


Returns the collection of columns that belong to this table.

Syntax


Script [ DataColumnCollection variable = ] DataTable.Columns

Property Value


variable Returns the DataColumnCollection that contains the DataColumn objects for the table.

The property is read only with no default value.

Remarks

The DataColumnCollection determines the schema of a table by defining the data type of each column.

NOTE: DataTable.Columns returns a null value if no DataColumn objects exist in the table.

Example

The following examples demonstrate using the Columns property to print the values of each column in each row of a table.

Private void ColumnsDemo ( DataTable myTable ) {

   foreach ( DataRow myRow in myTable.Rows ) {
      foreach ( DataColumn myCol in myTable.Columns ) {
         Response.Write ( myRow [ myCol ] );
      }
    }
}
  C# VB

Retrieving OleDb Data into a DataSet
Run Sample | View Source
Retrieving SQL Data into a DataSet
Run Sample | View Source
Retrieving XML Data into a DataSet
Run Sample | View Source

See Also

DataTable Members   DataColumnCollection   DataColumn Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note