DataSet Constructor (String)

DataSet Constructor (String)

.NET Framework 1.1

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

[Visual Basic]
Public Sub New( _
   ByVal dataSetName As String _
public DataSet(
   string dataSetName
public: DataSet(
   String* dataSetName
public function DataSet(
   dataSetName : String


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.


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

[Visual Basic] 
Private Sub CreateDataSet()
   Dim  myDataSet As DataSet
   myDataSet = New DataSet("aNewDataSet")
   ' Create two DataTable objects using a function.
   Dim table1 As DataTable = MakeTable("idTable1", "thing1")
   Dim table2 As DataTable = MakeTable("idTable2", "thing2")
   Console.WriteLine(myDataSet.DataSetName, myDataSet.Tables.Count)
End Sub

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

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataSet Class | DataSet Members | System.Data Namespace | DataSet Constructor Overload List | DataSetName | DataTable | DataTableCollection

© 2015 Microsoft