Name

DataType

Synopsis


Type dataType = DataColumn.DataType;

DataColumn.DataType = dataType;

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

Example

The following example demonstrates how to set the data type for a column:

DataColumn col = new DataColumn();

col.DataType = typeof(Int32);

Notes

This DataType property supports the base .NET Framework data types described in Table 24-4.

Table 24-4. NET Framework data types

Data type

Description

Boolean

A Boolean value. Instances of this type have the value true or false.

Byte

An 8-bit unsigned integer with values ranging from 0 to 255.

Char

A Unicode character with values ranging from hexadecimal 0x0000 to 0xFFFF.

DateTime

Represents dates and times with values ranging from January 1, 0001 12:00:00 midnight to December 31, 9999 11:59:50 P.M.

Decimal

A decimal number ranging from -79,228,162,514,264,337,593,543,950,335 through +79,228,162,514,264,337,593,543,950,335. The Decimal value type eliminates rounding errors in large numbers, typical in financial calculations.

Double

A double-precision 64-bit number ranging from -1.79769313486232e308 through +1.79769313486232e308. The Double type can also contain values -0, +0, PositiveInfinity, NegativeInfinity, and Not-a-Number (NaN).

Int16

A 16-bit signed integer with values ranging from -32,768 through +32,767.

Int32

A 32-bit signed integer with values ranging from -2,147,483,648 through +2,147,483,647.

Int64

A 64-bit signed integer with values ranging ...

Get ADO.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.