10 out of 26 rated this helpful - Rate this topic

DataTable Class

Represents one table of in-memory data.

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)
[SerializableAttribute]
public class DataTable : MarshalByValueComponent, IListSource, 
	ISupportInitializeNotification, ISupportInitialize, ISerializable, IXmlSerializable

The DataTable type exposes the following members.

  Name Description
Public method Supported by the XNA Framework DataTable() Initializes a new instance of the DataTable class with no arguments.
Public method Supported by the XNA Framework DataTable(String) Initializes a new instance of the DataTable class with the specified table name.
Protected method DataTable(SerializationInfo, StreamingContext) Initializes a new instance of the DataTable class with the SerializationInfo and the StreamingContext.
Public method Supported by the XNA Framework DataTable(String, String) Initializes a new instance of the DataTable class using the specified table name and namespace.
Top
  Name Description
Public property Supported by the XNA Framework CaseSensitive Indicates whether string comparisons within the table are case-sensitive.
Public property Supported by the XNA Framework ChildRelations Gets the collection of child relations for this DataTable.
Public property Supported by the XNA Framework Columns Gets the collection of columns that belong to this table.
Public property Supported by the XNA Framework Constraints Gets the collection of constraints maintained by this table.
Public property Supported by the XNA Framework Container Gets the container for the component. (Inherited from MarshalByValueComponent.)
Public property Supported by the XNA Framework DataSet Gets the DataSet to which this table belongs.
Public property Supported by the XNA Framework DefaultView Gets a customized view of the table that may include a filtered view, or a cursor position.
Public property Supported by the XNA Framework DesignMode Gets a value indicating whether the component is currently in design mode. (Inherited from MarshalByValueComponent.)
Public property Supported by the XNA Framework DisplayExpression Gets or sets the expression that returns a value used to represent this table in the user interface. The DisplayExpression property lets you display the name of this table in a user interface.
Protected property Supported by the XNA Framework Events Gets the list of event handlers that are attached to this component. (Inherited from MarshalByValueComponent.)
Public property Supported by the XNA Framework ExtendedProperties Gets the collection of customized user information.
Public property Supported by the XNA Framework HasErrors Gets a value indicating whether there are errors in any of the rows in any of the tables of the DataSet to which the table belongs.
Public property Supported by the XNA Framework IsInitialized Gets a value that indicates whether the DataTable is initialized.
Public property Supported by the XNA Framework Locale Gets or sets the locale information used to compare strings within the table.
Public property Supported by the XNA Framework MinimumCapacity Gets or sets the initial starting size for this table.
Public property Supported by the XNA Framework Namespace Gets or sets the namespace for the XML representation of the data stored in the DataTable.
Public property Supported by the XNA Framework ParentRelations Gets the collection of parent relations for this DataTable.
Public property Supported by the XNA Framework Prefix Gets or sets the namespace for the XML representation of the data stored in the DataTable.
Public property Supported by the XNA Framework PrimaryKey Gets or sets an array of columns that function as primary keys for the data table.
Public property RemotingFormat Gets or sets the serialization format.
Public property Supported by the XNA Framework Rows Gets the collection of rows that belong to this table.
Public property Supported by the XNA Framework Site Gets or sets an System.ComponentModel.ISite for the DataTable. (Overrides MarshalByValueComponent.Site.)
Public property Supported by the XNA Framework TableName Gets or sets the name of the DataTable.
Top
  Name Description
Public method Supported by the XNA Framework AcceptChanges Commits all the changes made to this table since the last time AcceptChanges was called.
Public method Supported by the XNA Framework BeginInit Begins the initialization of a DataTable that is used on a form or used by another component. The initialization occurs at run time.
Public method Supported by the XNA Framework BeginLoadData Turns off notifications, index maintenance, and constraints while loading data.
Public method Supported by the XNA Framework Clear Clears the DataTable of all data.
Public method Supported by the XNA Framework Clone Clones the structure of the DataTable, including all DataTable schemas and constraints.
Public method Supported by the XNA Framework Compute Computes the given expression on the current rows that pass the filter criteria.
Public method Supported by the XNA Framework Copy Copies both the structure and data for this DataTable.
Public method Supported by the XNA Framework CreateDataReader Returns a DataTableReader corresponding to the data within this DataTable.
Protected method Supported by the XNA Framework CreateInstance Infrastructure. Creates a new instance of DataTable.
Public method Supported by the XNA Framework Dispose() Releases all resources used by the MarshalByValueComponent. (Inherited from MarshalByValueComponent.)
Protected method Supported by the XNA Framework Dispose(Boolean) Releases the unmanaged resources used by the MarshalByValueComponent and optionally releases the managed resources. (Inherited from MarshalByValueComponent.)
Public method Supported by the XNA Framework EndInit Ends the initialization of a DataTable that is used on a form or used by another component. The initialization occurs at run time.
Public method Supported by the XNA Framework EndLoadData Turns on notifications, index maintenance, and constraints after loading data.
Public method Supported by the XNA Framework Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Supported by the XNA Framework Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from MarshalByValueComponent.)
Public method Supported by the XNA Framework GetChanges() Gets a copy of the DataTable that contains all changes made to it since it was loaded or AcceptChanges was last called.
Public method Supported by the XNA Framework GetChanges(DataRowState) Gets a copy of the DataTable containing all changes made to it since it was last loaded, or since AcceptChanges was called, filtered by DataRowState.
Public method Static member Supported by the XNA Framework GetDataTableSchema This method returns an XmlSchemaSet instance containing the Web Services Description Language (WSDL) that describes the DataTable for Web Services.
Public method Supported by the XNA Framework GetErrors Gets an array of DataRow objects that contain errors.
Public method Supported by the XNA Framework GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetObjectData Populates a serialization information object with the data needed to serialize the DataTable.
Protected method Supported by the XNA Framework GetRowType Infrastructure. Gets the row type.
Protected method Supported by the XNA Framework GetSchema Infrastructure. For a description of this member, see IXmlSerializable.GetSchema.
Public method Supported by the XNA Framework GetService Gets the implementer of the IServiceProvider. (Inherited from MarshalByValueComponent.)
Public method Supported by the XNA Framework GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Supported by the XNA Framework ImportRow Copies a DataRow into a DataTable, preserving any property settings, as well as original and current values.
Public method Supported by the XNA Framework Load(IDataReader) Fills a DataTable with values from a data source using the supplied IDataReader. If the DataTable already contains rows, the incoming data from the data source is merged with the existing rows.
Public method Supported by the XNA Framework Load(IDataReader, LoadOption) Fills a DataTable with values from a data source using the supplied IDataReader. If the DataTable already contains rows, the incoming data from the data source is merged with the existing rows according to the value of the loadOption parameter.
Public method Supported by the XNA Framework Load(IDataReader, LoadOption, FillErrorEventHandler) Fills a DataTable with values from a data source using the supplied IDataReader using an error-handling delegate.
Public method Supported by the XNA Framework LoadDataRow(Object[], Boolean) Finds and updates a specific row. If no matching row is found, a new row is created using the given values.
Public method Supported by the XNA Framework LoadDataRow(Object[], LoadOption) Finds and updates a specific row. If no matching row is found, a new row is created using the given values.
Protected method Supported by the XNA Framework MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by the XNA Framework Merge(DataTable) Merge the specified DataTable with the current DataTable.
Public method Supported by the XNA Framework Merge(DataTable, Boolean) Merge the specified DataTable with the current DataTable, indicating whether to preserve changes in the current DataTable.
Public method Supported by the XNA Framework Merge(DataTable, Boolean, MissingSchemaAction) Merge the specified DataTable with the current DataTable, indicating whether to preserve changes and how to handle missing schema in the current DataTable.
Public method Supported by the XNA Framework NewRow Creates a new DataRow with the same schema as the table.
Protected method Supported by the XNA Framework NewRowArray Infrastructure. Returns an array of DataRow.
Protected method Supported by the XNA Framework NewRowFromBuilder Creates a new row from an existing row.
Protected method Supported by the XNA Framework OnColumnChanged Raises the ColumnChanged event.
Protected method Supported by the XNA Framework OnColumnChanging Raises the ColumnChanging event.
Protected method Supported by the XNA Framework OnPropertyChanging Raises the PropertyChanged event.
Protected method OnRemoveColumn Notifies the DataTable that a DataColumn is being removed.
Protected method Supported by the XNA Framework OnRowChanged Raises the RowChanged event.
Protected method Supported by the XNA Framework OnRowChanging Raises the RowChanging event.
Protected method Supported by the XNA Framework OnRowDeleted Raises the RowDeleted event.
Protected method Supported by the XNA Framework OnRowDeleting Raises the RowDeleting event.
Protected method Supported by the XNA Framework OnTableCleared Raises the TableCleared event.
Protected method Supported by the XNA Framework OnTableClearing Raises the TableClearing event.
Protected method Supported by the XNA Framework OnTableNewRow Raises the TableNewRow event.
Public method Supported by the XNA Framework ReadXml(Stream) Reads XML schema and data into the DataTable using the specified Stream.
Public method Supported by the XNA Framework ReadXml(String) Reads XML schema and data into the DataTable from the specified file.
Public method Supported by the XNA Framework ReadXml(TextReader) Reads XML schema and data into the DataTable using the specified TextReader.
Public method Supported by the XNA Framework ReadXml(XmlReader) Reads XML Schema and Data into the DataTable using the specified XmlReader.
Public method Supported by the XNA Framework ReadXmlSchema(Stream) Reads an XML schema into the DataTable using the specified stream.
Public method Supported by the XNA Framework ReadXmlSchema(String) Reads an XML schema into the DataTable from the specified file.
Public method Supported by the XNA Framework ReadXmlSchema(TextReader) Reads an XML schema into the DataTable using the specified TextReader.
Public method Supported by the XNA Framework ReadXmlSchema(XmlReader) Reads an XML schema into the DataTable using the specified XmlReader.
Protected method Supported by the XNA Framework ReadXmlSerializable Infrastructure. Reads from an XML stream.
Public method Supported by the XNA Framework RejectChanges Rolls back all changes that have been made to the table since it was loaded, or the last time AcceptChanges was called.
Public method Supported by the XNA Framework Reset Resets the DataTable to its original state.
Public method Supported by the XNA Framework Select() Gets an array of all DataRow objects.
Public method Supported by the XNA Framework Select(String) Gets an array of all DataRow objects that match the filter criteria.
Public method Supported by the XNA Framework Select(String, String) Gets an array of all DataRow objects that match the filter criteria, in the specified sort order.
Public method Supported by the XNA Framework Select(String, String, DataViewRowState) Gets an array of all DataRow objects that match the filter in the order of the sort that match the specified state.
Public method Supported by the XNA Framework ToString Gets the TableName and DisplayExpression, if there is one as a concatenated string. (Overrides MarshalByValueComponent.ToString().)
Public method Supported by the XNA Framework WriteXml(Stream) Writes the current contents of the DataTable as XML using the specified Stream.
Public method Supported by the XNA Framework WriteXml(String) Writes the current contents of the DataTable as XML using the specified file.
Public method Supported by the XNA Framework WriteXml(TextWriter) Writes the current contents of the DataTable as XML using the specified TextWriter.
Public method Supported by the XNA Framework WriteXml(XmlWriter) Writes the current contents of the DataTable as XML using the specified XmlWriter.
Public method Supported by the XNA Framework WriteXml(Stream, Boolean) Writes the current contents of the DataTable as XML using the specified Stream. To save the data for the table and all its descendants, set the writeHierarchy parameter to true.
Public method Supported by the XNA Framework WriteXml(Stream, XmlWriteMode) Writes the current data, and optionally the schema, for the DataTable to the specified file using the specified XmlWriteMode. To write the schema, set the value for the mode parameter to WriteSchema.
Public method Supported by the XNA Framework WriteXml(String, Boolean) Writes the current contents of the DataTable as XML using the specified file. To save the data for the table and all its descendants, set the writeHierarchy parameter to true.
Public method Supported by the XNA Framework WriteXml(String, XmlWriteMode) Writes the current data, and optionally the schema, for the DataTable using the specified file and XmlWriteMode. To write the schema, set the value for the mode parameter to WriteSchema.
Public method Supported by the XNA Framework WriteXml(TextWriter, Boolean) Writes the current contents of the DataTable as XML using the specified TextWriter. To save the data for the table and all its descendants, set the writeHierarchy parameter to true.
Public method Supported by the XNA Framework WriteXml(TextWriter, XmlWriteMode) Writes the current data, and optionally the schema, for the DataTable using the specified TextWriter and XmlWriteMode. To write the schema, set the value for the mode parameter to WriteSchema.
Public method Supported by the XNA Framework WriteXml(XmlWriter, Boolean) Writes the current contents of the DataTable as XML using the specified XmlWriter.
Public method Supported by the XNA Framework WriteXml(XmlWriter, XmlWriteMode) Writes the current data, and optionally the schema, for the DataTable using the specified XmlWriter and XmlWriteMode. To write the schema, set the value for the mode parameter to WriteSchema.
Public method Supported by the XNA Framework WriteXml(Stream, XmlWriteMode, Boolean) Writes the current data, and optionally the schema, for the DataTable to the specified file using the specified XmlWriteMode. To write the schema, set the value for the mode parameter to WriteSchema. To save the data for the table and all its descendants, set the writeHierarchy parameter to true.
Public method Supported by the XNA Framework WriteXml(String, XmlWriteMode, Boolean) Writes the current data, and optionally the schema, for the DataTable using the specified file and XmlWriteMode. To write the schema, set the value for the mode parameter to WriteSchema. To save the data for the table and all its descendants, set the writeHierarchy parameter to true.
Public method Supported by the XNA Framework WriteXml(TextWriter, XmlWriteMode, Boolean) Writes the current data, and optionally the schema, for the DataTable using the specified TextWriter and XmlWriteMode. To write the schema, set the value for the mode parameter to WriteSchema. To save the data for the table and all its descendants, set the writeHierarchy parameter to true.
Public method Supported by the XNA Framework WriteXml(XmlWriter, XmlWriteMode, Boolean) Writes the current data, and optionally the schema, for the DataTable using the specified XmlWriter and XmlWriteMode. To write the schema, set the value for the mode parameter to WriteSchema. To save the data for the table and all its descendants, set the writeHierarchy parameter to true.
Public method Supported by the XNA Framework WriteXmlSchema(Stream) Writes the current data structure of the DataTable as an XML schema to the specified stream.
Public method Supported by the XNA Framework WriteXmlSchema(String) Writes the current data structure of the DataTable as an XML schema to the specified file.
Public method Supported by the XNA Framework WriteXmlSchema(TextWriter) Writes the current data structure of the DataTable as an XML schema using the specified TextWriter.
Public method Supported by the XNA Framework WriteXmlSchema(XmlWriter) Writes the current data structure of the DataTable as an XML schema using the specified XmlWriter.
Public method Supported by the XNA Framework WriteXmlSchema(Stream, Boolean) Writes the current data structure of the DataTable as an XML schema to the specified stream. To save the schema for the table and all its descendants, set the writeHierarchy parameter to true.
Public method Supported by the XNA Framework WriteXmlSchema(String, Boolean) Writes the current data structure of the DataTable as an XML schema to the specified file. To save the schema for the table and all its descendants, set the writeHierarchy parameter to true.
Public method Supported by the XNA Framework WriteXmlSchema(TextWriter, Boolean) Writes the current data structure of the DataTable as an XML schema using the specified TextWriter. To save the schema for the table and all its descendants, set the writeHierarchy parameter to true.
Public method Supported by the XNA Framework WriteXmlSchema(XmlWriter, Boolean) Writes the current data structure of the DataTable as an XML schema using the specified XmlWriter. To save the schema for the table and all its descendants, set the writeHierarchy parameter to true.
Top
  Name Description
Public event Supported by the XNA Framework ColumnChanged Occurs after a value has been changed for the specified DataColumn in a DataRow.
Public event Supported by the XNA Framework ColumnChanging Occurs when a value is being changed for the specified DataColumn in a DataRow.
Public event Supported by the XNA Framework Disposed Adds an event handler to listen to the Disposed event on the component. (Inherited from MarshalByValueComponent.)
Public event Supported by the XNA Framework Initialized Occurs after the DataTable is initialized.
Public event Supported by the XNA Framework RowChanged Occurs after a DataRow has been changed successfully.
Public event Supported by the XNA Framework RowChanging Occurs when a DataRow is changing.
Public event Supported by the XNA Framework RowDeleted Occurs after a row in the table has been deleted.
Public event Supported by the XNA Framework RowDeleting Occurs before a row in the table is about to be deleted.
Public event Supported by the XNA Framework TableCleared Occurs after a DataTable is cleared.
Public event Supported by the XNA Framework TableClearing Occurs when a DataTable is cleared.
Public event Supported by the XNA Framework TableNewRow Occurs when a new DataRow is inserted.
Top
  Name Description
Public Extension Method AsDataView Creates and returns a LINQ-enabled DataView object. (Defined by DataTableExtensions.)
Public Extension Method AsEnumerable Returns an IEnumerable<T> object, where the generic parameter T is DataRow. This object can be used in a LINQ expression or method query. (Defined by DataTableExtensions.)
Top
  Name Description
Protected field Supported by the XNA Framework fInitInProgress Infrastructure. Checks whether initialization is in progress. The initialization occurs at run time.
Top
  Name Description
Explicit interface implemetation Private property Supported by the XNA Framework IListSource.ContainsListCollection For a description of this member, see IListSource.ContainsListCollection.
Explicit interface implemetation Private method Supported by the XNA Framework IListSource.GetList For a description of this member, see IListSource.GetList.
Explicit interface implemetation Private method Supported by the XNA Framework IXmlSerializable.GetSchema For a description of this member, see IXmlSerializable.GetSchema.
Explicit interface implemetation Private method Supported by the XNA Framework IXmlSerializable.ReadXml For a description of this member, see IXmlSerializable.ReadXml.
Explicit interface implemetation Private method Supported by the XNA Framework IXmlSerializable.WriteXml For a description of this member, see IXmlSerializable.WriteXml.
Top

The DataTable is a central object in the ADO.NET library. Other objects that use the DataTable include the DataSet and the DataView.

When accessing DataTable objects, note that they are conditionally case sensitive. For example, if one DataTable is named "mydatatable" and another is named "Mydatatable", a string used to search for one of the tables is regarded as case sensitive. However, if "mydatatable" exists and "Mydatatable" does not, the search string is regarded as case insensitive. A DataSet can contain two DataTable objects that have the same TableName property value but different Namespace property values. For more information about working with DataTable objects, see Creating a DataTable (ADO.NET).

If you are creating a DataTable programmatically, you must first define its schema by adding DataColumn objects to the DataColumnCollection (accessed through the Columns property). For more information about adding DataColumn objects, see Adding Columns to a DataTable (ADO.NET).

To add rows to a DataTable, you must first use the NewRow method to return a new DataRow object. The NewRow method returns a row with the schema of the DataTable, as it is defined by the table's DataColumnCollection. The maximum number of rows that a DataTable can store is 16,777,216. For more information, see Adding Data to a DataTable.

The DataTable also contains a collection of Constraint objects that can be used to ensure the integrity of the data. For more information, see DataTable Constraints (ADO.NET).

There are many DataTable events that can be used to determine when changes are made to a table. These include RowChanged, RowChanging, RowDeleting, and RowDeleted. For more information about the events that can be used with a DataTable, see Handling DataTable Events (ADO.NET).

When an instance of DataTable is created, some of the read/write properties are set to initial values. For a list of these values, see the DataTable.DataTable constructor topic.

Note Note

The DataSet and DataTable objects inherit from MarshalByValueComponent, and support the ISerializable interface for .NET Framework remoting. These are the only ADO.NET objects that you can use for .NET Framework remoting.

The following example creates two DataTable objects and one DataRelation object, and adds the new objects to a DataSet. The tables are then displayed in a DataGridView control.


// Put the next line into the Declarations section.
private System.Data.DataSet dataSet;

private void MakeDataTables()
{
    // Run all of the functions. 
    MakeParentTable();
    MakeChildTable();
    MakeDataRelation();
    BindToDataGrid();
}

private void MakeParentTable()
{
    // Create a new DataTable.
    System.Data.DataTable table = new DataTable("ParentTable");
    // Declare variables for DataColumn and DataRow objects.
    DataColumn column;
    DataRow row;

    // Create new DataColumn, set DataType, 
    // ColumnName and add to DataTable.    
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.ColumnName = "id";
    column.ReadOnly = true;
    column.Unique = true;
    // Add the Column to the DataColumnCollection.
    table.Columns.Add(column);

    // Create second column.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.String");
    column.ColumnName = "ParentItem";
    column.AutoIncrement = false;
    column.Caption = "ParentItem";
    column.ReadOnly = false;
    column.Unique = false;
    // Add the column to the table.
    table.Columns.Add(column);

    // Make the ID column the primary key column.
    DataColumn[] PrimaryKeyColumns = new DataColumn[1];
    PrimaryKeyColumns[0] = table.Columns["id"];
    table.PrimaryKey = PrimaryKeyColumns;

    // Instantiate the DataSet variable.
    dataSet = new DataSet();
    // Add the new DataTable to the DataSet.
    dataSet.Tables.Add(table);

    // Create three new DataRow objects and add 
    // them to the DataTable
    for (int i = 0; i<= 2; i++)
    {
        row = table.NewRow();
        row["id"] = i;
        row["ParentItem"] = "ParentItem " + i;
        table.Rows.Add(row);
    }
}

private void MakeChildTable()
{
    // Create a new DataTable.
    DataTable table = new DataTable("childTable");
    DataColumn column;
    DataRow row;

    // Create first column and add to the DataTable.
    column = new DataColumn();
    column.DataType= System.Type.GetType("System.Int32");
    column.ColumnName = "ChildID";
    column.AutoIncrement = true;
    column.Caption = "ID";
    column.ReadOnly = true;
    column.Unique = true;

    // Add the column to the DataColumnCollection.
    table.Columns.Add(column);

    // Create second column.
    column = new DataColumn();
    column.DataType= System.Type.GetType("System.String");
    column.ColumnName = "ChildItem";
    column.AutoIncrement = false;
    column.Caption = "ChildItem";
    column.ReadOnly = false;
    column.Unique = false;
    table.Columns.Add(column);

    // Create third column.
    column = new DataColumn();
    column.DataType= System.Type.GetType("System.Int32");
    column.ColumnName = "ParentID";
    column.AutoIncrement = false;
    column.Caption = "ParentID";
    column.ReadOnly = false;
    column.Unique = false;
    table.Columns.Add(column);

    dataSet.Tables.Add(table);

    // Create three sets of DataRow objects, 
    // five rows each, and add to DataTable.
    for(int i = 0; i <= 4; i ++)
    {
        row = table.NewRow();
        row["childID"] = i;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 0 ;
        table.Rows.Add(row);
    }
    for(int i = 0; i <= 4; i ++)
    {
        row = table.NewRow();
        row["childID"] = i + 5;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 1 ;
        table.Rows.Add(row);
    }
    for(int i = 0; i <= 4; i ++)
    {
        row = table.NewRow();
        row["childID"] = i + 10;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 2 ;
        table.Rows.Add(row);
    }
}

private void MakeDataRelation()
{
    // DataRelation requires two DataColumn 
    // (parent and child) and a name.
    DataColumn parentColumn = 
        dataSet.Tables["ParentTable"].Columns["id"];
    DataColumn childColumn = 
        dataSet.Tables["ChildTable"].Columns["ParentID"];
    DataRelation relation = new 
        DataRelation("parent2Child", parentColumn, childColumn);
    dataSet.Tables["ChildTable"].ParentRelations.Add(relation);
}

private void BindToDataGrid()
{
    // Instruct the DataGrid to bind to the DataSet, with the 
    // ParentTable as the topmost DataTable.
    dataGrid1.SetDataBinding(dataSet,"ParentTable");
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

This type is safe for multithreaded read operations. You must synchronize any write operations.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Better to use DataGridView in example
The example still uses a DataGrid. This is a legacy class. The use of a DataGridView is preferred. It would, therefore, make sense to use the latter in examples.
DataTable.ImportRow Method
This method copies the row of one table to another. But, If the new row violates a Constraint it won’t be added to the data table. Constraints, such as ,if the destination table schema is not defined then, during run time, it doesn't report this or doesn't rises an exception.