This documentation is archived and is not being maintained.

DataSet Constructor ()

.NET Framework 1.1

Initializes a new instance of the DataSet class.

[Visual Basic]
Public Sub New()
public DataSet();
public: DataSet();
public function DataSet();


This implementation of the DataSet constructor takes no parameters, and creates a default name, "NewDataSet", for the new instance.

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, and adds two DataTable objects to it.

[Visual Basic] 
Private Sub CreateDataSet()
   Dim myDataSet As DataSet
   myDataSet = New DataSet
   ' Create two DataTable objects using a function.
   Dim table1 As DataTable = MakeTable("idTable1", "thing1")
   Dim table2 As DataTable = MakeTable("idTable2", "thing2")
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 | DataTable | DataTableCollection