DataType
TypedataType
= DataColumn.DataType; DataColumn.DataType =dataType
;
Gets or sets the data type of the column data as a .NET Framework data type.
The following example demonstrates how to set the data type for a column:
DataColumn col = new DataColumn(); col.DataType = typeof(Int32);
This DataType
property supports the base
.NET Framework data types described
in Table 24-4.
The value for the DataType
property can also be
set using the DataColumn
constructor as shown in
this sample:
DataColumn col = new DataColumn("MyColumn", typeof(System.String));
If the AutoIncrement
property of the column is set
to true
, the DataType
property
must be set to an integer type; an
ArgumentException
is raised if an attempt is made
to set the DataType
property to a noninteger data
type.
An ArgumentException
is raised if the value of the
DataType
property is changed once there is data in
the table.
The default value for this property is String
.