|
|
You use an object of the DataColumn class to represent a column. You can also store multiple DataColumn objects in a DataRow. Table 11.6 shows some of the DataColumn properties.
PROPERTY | TYPE | DESCRIPTION |
---|---|---|
AllowDBNull | bool | Gets or sets a bool value that indicates whether null values are allowed in this DataColumn object. The default is true. |
AutoIncrement | bool | Gets or sets a bool value that indicates whether the DataColumn object automatically increments the value of the column for new rows. The default is false. |
AutoIncrementSeed | long | Gets or sets the starting value for the DataColumn object. Applies only when the AutoIncrement property is set to true. The default is 0. |
AutoIncrementStep | long | Gets or sets the increment used. Applies only when the AutoIncrement property is set to true. The default is 1. |
Caption | string | Gets or sets the caption for the column. The caption for the column is shown in Windows forms. The default is null. |
ColumnName | string | Gets or sets the name of the DataColumn object. |
ColumnMapping | MappingType | Gets or sets the MappingType of the DataColumn object. This determines how a DataColumn is saved in an XML document using the WriteXml() method. |
DataType | Type | Gets or sets the .NET data type used to represent the column value stored in the DataColumn object. This can be Boolean, Byte, Char, DateTime, Decimal, Double, Int16, Int32, Int64, SByte, Single, String, TimeSpan, UInt16, or UInt64. |
DafaultValue | object | Gets or sets the default value for the DataColumn when new rows are created. When AutoIncrement is set to true, DefaultValue is not used. |
MaxLength | int | Gets or sets the maximum length of text that may be stored in a DataColumn object. The default is -1. |
Ordinal | int | Gets the numeric position of the DataColumn object (0 is the first object). |
ReadOnly | bool | Gets or sets a bool value that indicates whether the DataColumn object can be changed once it has been added to a DataRow. The default is false. |
Table | DataTable | Gets the DataTable to which the DataColumn object belongs. |
Unique | bool | Gets or sets a bool value that indicates whether the DataColumn values in each DataRow object must be unique. The default is false. |
You'll see the use of some of these properties, methods, and events later in this chapter.
|
|