DataColumn.ColumnName Property

 

Gets or sets the name of the column in the DataColumnCollection.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

member ColumnName : string with get, set

Property Value

Type: System.String

The name of the column.

Exception Condition
ArgumentException

The property is set to null or an empty string and the column belongs to a collection.

DuplicateNameException

A column with the same name already exists in the collection. The name comparison is not case sensitive.

When a DataColumn is created, it has no ColumnName value. However, when the DataColumn is added to a DataColumnCollection for a DataTable object, it is given a default name ("Column1", "Column2", and so on).

By default, the Caption value is set to the ColumnName value.

The following examples gets the ColumnName for every column in every table in a DataSet. The example also shows how to create a DataColumn with a new ColumnName.

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

.NET Framework
Available since 1.1
Return to top
Show: