Export (0) Print
Expand All

DataTable.Clone Method

Clones the structure of the DataTable, including all DataTable schemas and constraints.

[Visual Basic]
Public Overridable Function Clone() As DataTable
[C#]
public virtual DataTable Clone();
[C++]
public: virtual DataTable* Clone();
[JScript]
public function Clone() : DataTable;

Return Value

A new DataTable with the same schema as the current DataTable.

Remarks

Note   If these classes have been derived, the clone will also be of the same derived classes.

Example

[Visual Basic, C#, C++] The following example creates a clone of a DataTable object's schema.

[Visual Basic] 
Private Sub GetClone(ByVal myDataTable As DataTable)
    ' Get a clone of the original DataTable.
    Dim cloneTable As DataTable
    cloneTable = myDataTable.Clone()
    ' Insert code to work with clone of the DataTable.
 End Sub

[C#] 
private void GetClone(DataTable myDataTable){
    // Get a clone of the original DataTable.
    DataTable cloneTable;
    cloneTable = myDataTable.Clone();
    // Insert code to work with clone of the DataTable.
 }

[C++] 
private:
void GetClone(DataTable* myDataTable){
    // Get a clone of the original DataTable.
    DataTable* cloneTable;
    cloneTable = myDataTable->Clone();
    // Insert code to work with clone of the DataTable.
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataTable Class | DataTable Members | System.Data Namespace

Show:
© 2014 Microsoft