Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DataSet Constructor ()

.NET Framework 1.1

Initializes a new instance of the DataSet class.

[Visual Basic]
Public Sub New()
[C#]
public DataSet();
[C++]
public: DataSet();
[JScript]
public function DataSet();

Remarks

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.

Example

[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")
   myDataSet.Tables.Add(table1)
   myDataSet.Tables.Add(table2)
   Console.WriteLine(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"))
   myTable.Columns.Add(myColumn)
   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.

Requirements

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

Show:
© 2014 Microsoft. All rights reserved.