Represents the schema of a column in a System.Data.DataTable.
See Also: DataColumn Members
The System.Data.DataColumn is the fundamental building block for creating the schema of a System.Data.DataTable. You build the schema by adding one or more System.Data.DataColumn objects to the System.Data.DataColumnCollection. For more information, see Adding Columns to a Table.
Each System.Data.DataColumn has a DataColumn.DataType property that determines the kind of data the System.Data.DataColumn contains. For example, you can restrict the data type to integers, or strings, or decimals. Because data that is contained by the System.Data.DataTable is typically merged back into its original data source, you must match the data types to those in the data source. For more information, see Mapping .NET Framework Data Provider Data Types to .NET Framework Data Types.
Properties such as DataColumn.AllowDBNull, DataColumn.Unique, and DataColumn.ReadOnly put restrictions on the entry and updating of data, thereby helping to guarantee data integrity. You can also use the DataColumn.AutoIncrement, DataColumn.AutoIncrementSeed, and DataColumn.AutoIncrementStep properties to control automatic data generation. For more information about DataColumn.AutoIncrement columns, see Creating AutoIncrement Columns. For more information, see Defining a Primary Key for a Table.
You can also make sure that values in a System.Data.DataColumn are unique by creating a System.Data.UniqueConstraint and adding it to the System.Data.ConstraintCollection of the System.Data.DataTable to which the System.Data.DataColumn belongs. For more information, see Adding Constraints to a Table.
You can use the DataColumn.Expression property of the System.Data.DataColumn object to calculate the values in a column, or create an aggregate column. For more information, see Creating Expression Columns.