Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DataSet.DataSet(String) Constructor

Initializes a new instance of a DataSet class with the given name.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

'Declaration
Public Sub New ( _
	dataSetName As String _
)
'Usage
Dim dataSetName As String

Dim instance As New DataSet(dataSetName)
public DataSet (
	String dataSetName
)
public function DataSet (
	dataSetName : String
)
Not applicable.

Parameters

dataSetName

The name of the 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.

The following example creates a new DataSet, to which two DataTable objects are added.

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2015 Microsoft