DataSet DataSet DataSet DataSet Constructors

定义

重载

DataSet() DataSet() DataSet()

初始化 DataSet 类的新实例。Initializes a new instance of the DataSet class.

DataSet(String) DataSet(String) DataSet(String) DataSet(String)

用给定名称初始化 DataSet 类的新实例。Initializes a new instance of a DataSet class with the given name.

DataSet(SerializationInfo, StreamingContext) DataSet(SerializationInfo, StreamingContext) DataSet(SerializationInfo, StreamingContext) DataSet(SerializationInfo, StreamingContext)

初始化具有给定序列化信息和上下文的 DataSet 类的新实例。Initializes a new instance of a DataSet class that has the given serialization information and context.

DataSet(SerializationInfo, StreamingContext, Boolean) DataSet(SerializationInfo, StreamingContext, Boolean) DataSet(SerializationInfo, StreamingContext, Boolean) DataSet(SerializationInfo, StreamingContext, Boolean)

初始化 DataSet 类的新实例。Initializes a new instance of the DataSet class.

DataSet() DataSet() DataSet()

初始化 DataSet 类的新实例。Initializes a new instance of the DataSet class.

public:
 DataSet();
public DataSet ();
Public Sub New ()

示例

下面的示例创建一个新DataSet的,并向DataTable其中添加两个对象。The following example creates a new DataSet, and adds two DataTable objects to it.

Private Sub CreateDataSet()
    Dim dataSet As New DataSet()

    ' Create two DataTable objects using a function.
    Dim table1 As DataTable = MakeTable("idTable1", "thing1")
    Dim table2 As DataTable = MakeTable("idTable2", "thing2")
    dataSet.Tables.Add(table1)
    dataSet.Tables.Add(table2)
    Console.WriteLine(dataSet.Tables.Count)
End Sub
 
 
Private Function MakeTable(c1Name As String, _
    c2Name As String) As DataTable
    Dim table As New DataTable
    
    ' Add two DataColumns
    Dim column As New DataColumn( _
        c1Name, System.Type.GetType("System.Integer"))
    table.Columns.Add(column)
    column = New DataColumn(c2Name, _
        System.Type.GetType("System.String"))
    MakeTable = table
End Function

注解

DataSet构造函数的实现不使用任何参数,并为新实例创建默认名称 "NewDataSet"。This implementation of the DataSet constructor takes no parameters, and creates a default name, "NewDataSet," for the new instance.

需要的DataSet名称才能确保的 XML 表示形式DataSet始终具有文档元素的名称,该元素是架构定义中的最高级别的元素。A name for the DataSet is required to ensure that the XML representation of the DataSet always has a name for the document element, which is the highest-level element in a schema definition.

另请参阅

DataSet(String) DataSet(String) DataSet(String) DataSet(String)

用给定名称初始化 DataSet 类的新实例。Initializes a new instance of a DataSet class with the given name.

public:
 DataSet(System::String ^ dataSetName);
public DataSet (string dataSetName);
new System.Data.DataSet : string -> System.Data.DataSet
Public Sub New (dataSetName As String)

参数

dataSetName
String String String String

DataSet 的名称。The name of the DataSet.

示例

下面的示例创建一个新DataSet的,其中添加DataTable了两个对象。The following example creates a new DataSet, to which two DataTable objects are added.

Private Sub CreateDataSet()
    Dim  dataSet As New DataSet("aNewDataSet")

    ' Create two DataTable objects using a function.
    Dim table1 As DataTable = MakeTable("idTable1", "thing1")
    Dim table2 As DataTable = MakeTable("idTable2", "thing2")

    dataSet.Tables.Add(table1)
    dataSet.Tables.Add(table2)
    Console.WriteLine(dataSet.DataSetName, dataSet.Tables.Count)
End Sub


Private Function MakeTable(c1Name As String, c2Name As String) _
    As DataTable
    Dim table As New DataTable
    
    ' Add two DataColumns
    Dim column As New DataColumn( _
        c1Name, System.Type.GetType("System.Integer"))
    table.Columns.Add(column)
    column = New DataColumn(c2Name, _
        System.Type.GetType("System.String"))
    table.Columns.Add(column)
    MakeTable = table
End Function

注解

需要的DataSet名称才能确保的 XML 表示形式DataSet始终具有文档元素的名称,该元素是架构定义中的最高级别的元素。A name for the DataSet is required to ensure that the XML representation of the DataSet always has a name for the document element, which is the highest level element in a schema definition.

另请参阅

DataSet(SerializationInfo, StreamingContext) DataSet(SerializationInfo, StreamingContext) DataSet(SerializationInfo, StreamingContext) DataSet(SerializationInfo, StreamingContext)

初始化具有给定序列化信息和上下文的 DataSet 类的新实例。Initializes a new instance of a DataSet class that has the given serialization information and context.

protected:
 DataSet(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected DataSet (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Data.DataSet : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Data.DataSet
Protected Sub New (info As SerializationInfo, context As StreamingContext)

参数

info
SerializationInfo SerializationInfo SerializationInfo SerializationInfo

序列化或反序列化对象所需的数据。The data needed to serialize or deserialize an object.

context
StreamingContext StreamingContext StreamingContext StreamingContext

给定序列化流的源和目标。The source and destination of a given serialized stream.

注解

重要

将此对象的实例与不受信任的数据一起使用存在安全风险。Using an instance of this object with untrusted data is a security risk. 仅将此对象与受信任的数据一起使用。Use this object only with trusted data. 有关详细信息,请参阅数据验证For more information, see Data Validation.

DataSet(SerializationInfo, StreamingContext, Boolean) DataSet(SerializationInfo, StreamingContext, Boolean) DataSet(SerializationInfo, StreamingContext, Boolean) DataSet(SerializationInfo, StreamingContext, Boolean)

初始化 DataSet 类的新实例。Initializes a new instance of the DataSet class.

protected:
 DataSet(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context, bool ConstructSchema);
protected DataSet (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, bool ConstructSchema);
new System.Data.DataSet : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext * bool -> System.Data.DataSet
Protected Sub New (info As SerializationInfo, context As StreamingContext, ConstructSchema As Boolean)

参数

ConstructSchema
Boolean Boolean Boolean Boolean

布尔值。The boolean value.

注解

重要

将此对象的实例与不受信任的数据一起使用存在安全风险。Using an instance of this object with untrusted data is a security risk. 仅将此对象与受信任的数据一起使用。Use this object only with trusted data. 有关详细信息,请参阅数据验证For more information, see Data Validation.

适用于