Export (0) Print
Expand All

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 _
)
[C#]
public DataSet(
   string dataSetName
);
[C++]
public: DataSet(
   String* dataSetName
);
[JScript]
public function DataSet(
   dataSetName : String
);

Parameters

dataSetName
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.

Example

[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")
   myDataSet.Tables.Add(table1)
   myDataSet.Tables.Add(table2)
   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"))
   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 | DataSetName | DataTable | DataTableCollection

Show:
© 2015 Microsoft