.NET Framework Class Library
DataSet Constructor (String)
Initializes a new instance of a DataSet class with the given name.
Assembly: System.Data (in System.Data.dll)
Syntax
Visual Basic
Public Sub New ( _ dataSetName As String _ )
C#
public DataSet( string dataSetName )
Visual C++
public:
DataSet(
String^ dataSetName
)
F#
new : dataSetName:string -> DataSet
Parameters
- dataSetName
- Type: System.String
The name of the DataSet.
Remarks
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.
Examples
The following example creates a new DataSet, to which two DataTable objects are added.
Visual Basic
Private Sub CreateDataSet() Dim dataSet As DataSet = 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 DataColumn = 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
Version Information
.NET Framework
Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0.NET Framework Client Profile
Supported in: 4, 3.5 SP1Platforms
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.
See Also