NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataColumn Constructor (String, Type, String)

Initializes a new instance of the DataColumn class using the specified name, data type, and expression.

[Visual Basic]
Overloads Public Sub New( _
   ByVal columnName As String, _
   ByVal dataType As Type, _
   ByVal expr As String _
)
[C#]
public DataColumn(
   string columnName,
   Type dataType,
   string expr
);
[C++]
public: DataColumn(
   String* columnName,
   Type* dataType,
   String* expr
);
[JScript]
public function DataColumn(
   columnName : String,
   dataType : Type,
   expr : String
);

Parameters

columnName
A string that represents the name of the column to be created. If set to a null reference (in Visual Basic Nothing) or an empty string (""), a default name will be given when added to the columns collection.
dataType
A supported DataType.
expr
The expression used to create this column. For more details, see the Expression property.

Exceptions

Exception Type Condition
ArgumentNullException No dataType was specified.

Example [Visual Basic]

The following example creates a computed column.

[Visual Basic]

Private Sub AddDataColumn()
   Dim myColumn As DataColumn 
   Dim dt As System.Type

   dt = New System.Type.GetType("System.Currency")
   myColumn = New DataColumn("Tax", dt, "UnitPrice * .0862")
   ' Set various properties.
   With myColumn
      .Unique = False
      .AutoIncrement = False
      .ReadOnly = True
   End With
   ' Add to Columns collection.
   myTable.Columns.Add myColumn
End Sub

See Also

DataColumn Class | DataColumn Members | System.Data Namespace | DataColumn Constructor Overload List | DefaultValue | ColumnName | Caption | DataTable | DataType | Expression