System.Data.Common Namespace DataColumnMapping Class
Returns a DataColumn from the given DataTable using the MissingSchemaAction and the type of the DataColumn.
[ VB ]
Public Function GetDataColumnBySchemaAction ( _
ByVal dataTable As DataTable, _
ByVal dataType As Type, _
ByVal schemaAction As MissingSchemaAction _
) As DataColumn
[ C# ]
public DataColumn GetDataColumnBySchemaAction (
DataTable dataTable,
Type dataType,
MissingSchemaAction schemaAction
);
[ C++ ]
public: DataColumn* GetDataColumnBySchemaAction (
DataTable* dataTable,
Type* dataType,
MissingSchemaAction schemaAction
);
[ JScript ]
public function GetDataColumnBySchemaAction (
dataTable : DataTable,
dataType : Type,
schemaAction : MissingSchemaAction
) : DataColumn;
- dataTable
- The DataTable to get the column from.
- dataType
- The Type of the data column.
- schemaAction
- One of the MissingSchemaAction values.
A DataColumn.
If no column of the given dataType exists in the specified dataTable, a null reference is returned, and the following happens for the given MissingSchemaAction:
MissingSchemaAction |
Action Taken |
Error |
An exception is thrown. |
Ignore |
Returns a null. |
Add |
A DataColumn of type dataType is created, but is not added to the dataTable. |
The following example gets the DataColumn that is of type Single for a given DataTable. If no column of type Single exists in the DataTable, a null reference is returned.
void CreateDataColumn ( DataTable myTable, DataColumnMapping myMap ) {
DataColumn currentCol = myMap.GetDataColumnBySchemaAction (
myTable, typeof ( Single ), MissingSchemaAction.Ignore );
}
Sub CreateDataColumn ( myTable As DataTable, myMap As DataColumnMapping )
Dim currentCol As DataColumn = myMap.GetDataColumnBySchemaAction ( _
myTable, GetType ( Single ), MissingSchemaAction.Ignore )
End Sub |
|
C# |
VB |
DataColumnMapping Members