24.1 Comments/Troubleshooting

The commonly used public properties of the DataColumn class are listed in Table 24-1.

Table 24-1. DataColumn properties

Property

Description

AllowDBNull

Gets or sets whether null values can be stored in the column.

AutoIncrement

Gets or sets whether the column automatically increments with each new row added to the table.

AutoIncrementSeed

Gets or sets the amount that an automatically incrementing column is incremented each time a row is added to the table.

AutoIncrementStep

Gets or sets the starting value for an automatically incrementing column.

Caption

Gets or sets the caption for the column used as the default value for the Caption property in controls that support its display.

ColumnMapping

Gets or sets how column data is written when it is saved as XML.

ColumnName

Gets or sets the name of the column.

DataType

Gets or sets the data type of the column data as one of the .NET Framework data types.

DefaultValue

Gets or sets the value that is automatically assigned to the column when a new row is created.

Expression

Gets or sets an expression that calculates the value of the column.

MaxLength

Gets or sets the maximum length for a column with a text data type in characters.

Namespace

Gets or sets the XML namespace for the XML representation of the data stored in the column.

Ordinal

Gets the position of the column within the column collection of the table.

Prefix

Gets or sets the XML prefix for the XML representation of the data stored in the column.

ReadOnly

Gets or sets a value that indicates whether the data in the column can be changed once the row containing the column is added to a table.

Table

Gets the table that the column has been assigned to.

Unique

Gets or sets a value indicating whether the value for each row in the column must be unique.

The commonly used public collections of the DataColumn class are listed in Table 24-2.

Table 24-2. DataColumn collections

Collection

Description

ExtendedProperties

The ExtendedProperties property accesses the PropertyCollection collection that contains custom information for the DataColumn as a collection of key and value pairs.

The DataColumn class is contained within the System.Data namespace. The DataColumn class inherits from MarshalByValueComponent. It's safe for multithreaded read operations; multithreaded write operations must be synchronized. DataColumn objects cannot be passed between different application domains.



    Part I: ADO.NET Tutorial
    Part II: ADO.NET Core Classes
    Part III: API Quick Reference