asp.net.ph

DataSet Constructor ( )

System.Data Namespace   DataSet Class


Initializes a new instance of the DataSet class.

[ VB ]
Public Sub New ( )

[ C# ]
public DataSet ( );

[ C++ ]
public: DataSet ( );

[ JScript ]
public function DataSet ( );

Remarks

This implementation of the DataSet constructor takes no parameters, and initializes 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

The following example initializes a new DataSet, and adds two DataTable objects.

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 )
   Response.Write ( 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
See Also

DataSet Members   DataSet Constructor Overload List   DataTable   DataTableCollection Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph