Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

DataColumn Class

Represents the schema of a column in a DataTable.

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)
type DataColumn =  
    class 
        inherit MarshalByValueComponent 
    end

The DataColumn type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkDataColumn()Initializes a new instance of a DataColumn class as type string.
Public methodSupported by the XNA FrameworkDataColumn(String)Initializes a new instance of the DataColumn class, as type string, using the specified column name.
Public methodSupported by the XNA FrameworkDataColumn(String, Type)Initializes a new instance of the DataColumn class using the specified column name and data type.
Public methodSupported by the XNA FrameworkDataColumn(String, Type, String)Initializes a new instance of the DataColumn class using the specified name, data type, and expression.
Public methodSupported by the XNA FrameworkDataColumn(String, Type, String, MappingType)Initializes a new instance of the DataColumn class using the specified name, data type, expression, and value that determines whether the column is an attribute.
Top
  NameDescription
Public propertySupported by the XNA FrameworkAllowDBNullGets or sets a value that indicates whether null values are allowed in this column for rows that belong to the table.
Public propertySupported by the XNA FrameworkAutoIncrementGets or sets a value that indicates whether the column automatically increments the value of the column for new rows added to the table.
Public propertySupported by the XNA FrameworkAutoIncrementSeedGets or sets the starting value for a column that has its AutoIncrement property set to true. The default is 0.
Public propertySupported by the XNA FrameworkAutoIncrementStepGets or sets the increment used by a column with its AutoIncrement property set to true.
Public propertySupported by the XNA FrameworkCaptionGets or sets the caption for the column.
Public propertySupported by the XNA FrameworkColumnMappingGets or sets the MappingType of the column.
Public propertySupported by the XNA FrameworkColumnNameGets or sets the name of the column in the DataColumnCollection.
Public propertySupported by the XNA FrameworkContainerGets the container for the component. (Inherited from MarshalByValueComponent.)
Public propertySupported by the XNA FrameworkDataTypeGets or sets the type of data stored in the column.
Public propertySupported by the XNA FrameworkDateTimeModeGets or sets the DateTimeMode for the column.
Public propertySupported by the XNA FrameworkDefaultValueGets or sets the default value for the column when you are creating new rows.
Public propertySupported by the XNA FrameworkDesignModeGets a value indicating whether the component is currently in design mode. (Inherited from MarshalByValueComponent.)
Protected propertySupported by the XNA FrameworkEventsGets the list of event handlers that are attached to this component. (Inherited from MarshalByValueComponent.)
Public propertySupported by the XNA FrameworkExpressionGets or sets the expression used to filter rows, calculate the values in a column, or create an aggregate column.
Public propertySupported by the XNA FrameworkExtendedPropertiesGets the collection of custom user information associated with a DataColumn.
Public propertySupported by the XNA FrameworkMaxLengthGets or sets the maximum length of a text column.
Public propertySupported by the XNA FrameworkNamespaceGets or sets the namespace of the DataColumn.
Public propertySupported by the XNA FrameworkOrdinalGets the (zero-based) position of the column in the DataColumnCollection collection.
Public propertySupported by the XNA FrameworkPrefixGets or sets an XML prefix that aliases the namespace of the DataTable.
Public propertySupported by the XNA FrameworkReadOnlyGets or sets a value that indicates whether the column allows for changes as soon as a row has been added to the table.
Public propertySupported by the XNA FrameworkSiteGets or sets the site of the component. (Inherited from MarshalByValueComponent.)
Public propertySupported by the XNA FrameworkTableGets the DataTable to which the column belongs to.
Public propertySupported by the XNA FrameworkUniqueGets or sets a value that indicates whether the values in each row of the column must be unique.
Top
  NameDescription
Protected methodSupported by the XNA FrameworkCheckNotAllowNullInfrastructure. This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
Protected methodSupported by the XNA FrameworkCheckUniqueInfrastructure. This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
Public methodSupported by the XNA FrameworkDispose()Releases all resources used by the MarshalByValueComponent. (Inherited from MarshalByValueComponent.)
Protected methodSupported by the XNA FrameworkDispose(Boolean)Releases the unmanaged resources used by the MarshalByValueComponent and optionally releases the managed resources. (Inherited from MarshalByValueComponent.)
Public methodSupported by the XNA FrameworkEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from MarshalByValueComponent.)
Public methodSupported by the XNA FrameworkGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetServiceGets the implementer of the IServiceProvider. (Inherited from MarshalByValueComponent.)
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkOnPropertyChangingThis member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
Protected methodSupported by the XNA FrameworkRaisePropertyChangingThis member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
Public methodSupported by the XNA FrameworkSetOrdinalChanges the ordinal or position of the DataColumn to the specified ordinal or position.
Public methodSupported by the XNA FrameworkToStringGets the Expression of the column, if one exists. (Overrides MarshalByValueComponent.ToString().)
Top
  NameDescription
Public eventSupported by the XNA FrameworkDisposedAdds an event handler to listen to the Disposed event on the component. (Inherited from MarshalByValueComponent.)
Top

The DataColumn is the fundamental building block for creating the schema of a DataTable. You build the schema by adding one or more DataColumn objects to the DataColumnCollection. For more information, see Adding Columns to a DataTable.

Each DataColumn has a DataType property that determines the kind of data the DataColumn contains. For example, you can restrict the data type to integers, or strings, or decimals. Because data that is contained by the 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 Data Type Mappings in ADO.NET.

Properties such as AllowDBNull, Unique, and ReadOnly put restrictions on the entry and updating of data, thereby helping to guarantee data integrity. You can also use the AutoIncrement, AutoIncrementSeed, and AutoIncrementStep properties to control automatic data generation. For more information about AutoIncrement columns, see Creating AutoIncrement Columns. For more information, see Defining Primary Keys.

You can also make sure that values in a DataColumn are unique by creating a UniqueConstraint and adding it to the ConstraintCollection of the DataTable to which the DataColumn belongs. For more information, see DataTable Constraints.

To create a relation between DataColumn objects, create a DataRelation object and add it to the DataRelationCollection of a DataSet.

You can use the Expression property of the DataColumn object to calculate the values in a column, or create an aggregate column. For more information, see Creating Expression Columns.

The following example creates a DataTable with several DataColumn objects.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

This type is safe for multithreaded read operations. You must synchronize any write operations.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.