This documentation is archived and is not being maintained.

DataSet.Copy Method

Copies both the structure and data for this DataSet.

[Visual Basic]
Public Function Copy() As DataSet
[C#]
public DataSet Copy();
[C++]
public: DataSet* Copy();
[JScript]
public function Copy() : DataSet;

Return Value

A new DataSet with the same structure (table schemas, relations, and constraints) and data as this DataSet.

Note   If these classes have been subclassed, the copy will also be of the same subclasses.

Example

[Visual Basic, C#, C++] The following example uses the Copy method to create a copy of the original DataSet.

[Visual Basic] 
Private Sub CopyDataSet(ByVal myDataSet As DataSet )
   ' Create an object variable for the copy.
   Dim copyDataSet As DataSet
   copyDataSet = myDataSet.Copy()
   ' Insert code to work with the copy.
End Sub

[C#] 
private void CopyDataSet(DataSet myDataSet){
   // Create an object variable for the copy.
   DataSet copyDataSet;
   copyDataSet = myDataSet.Copy();
   // Insert code to work with the copy.
}

[C++] 
private:
 void CopyDataSet(DataSet* myDataSet){
    // Create an object variable for the copy.
    DataSet* copyDataSet;
    copyDataSet = myDataSet->Copy();
    // Insert code to work with the copy.
 }

[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

See Also

DataSet Class | DataSet Members | System.Data Namespace | Clone

Show: