DataSet.Copy 方法

定义

复制该 DataSet 的结构和数据。Copies both the structure and data for this DataSet.

public:
 System::Data::DataSet ^ Copy();
public System.Data.DataSet Copy ();
member this.Copy : unit -> System.Data.DataSet
Public Function Copy () As DataSet

返回

新的 DataSet,具有与该 DataSet 相同的结构(表架构、关系和约束)和数据。A new DataSet with the same structure (table schemas, relations, and constraints) and data as this DataSet.


如果已创建这些类的子类,则副本也将属于相同的子类。If these classes have been subclassed, the copy will also be of the same subclasses.

示例

下面的示例使用 Copy 方法创建原始 DataSet的副本。The following example uses the Copy method to create a copy of the original DataSet.

private void CopyDataSet(DataSet dataSet)
{
    // Create an object variable for the copy.
    DataSet copyDataSet;
    copyDataSet = dataSet.Copy();

    // Insert code to work with the copy.
}
Private Sub CopyDataSet(ByVal dataSet As DataSet )
    ' Create an object variable for the copy.
    Dim copyDataSet As DataSet = dataSet.Copy()

    ' Insert code to work with the copy.
End Sub

适用于

另请参阅