Print
The DataSet is an in-memory database – a collection of virtual tables with means to populate, examine, modify and deleting delete the tables and the data within them. You can also define and manipulate the relationships between the tables and tables, create and enforce constraints to maintain those relationships. Surprisingly, the data that populates the tables within a DataSet can and frequently does come from different data sources, leading to very powerful flexibility in connecting and maintaining data in various server sources.
 
 

The primary purpose of a DataSet is to allow the user to operate on data from a server in a disconnected mode. The temporary separation of data from the server is a desirable thing because it frees memory on the server, as well as connection and network resources. The DataSet allows data to be ‘borrowed’ from the server in relatively small usable chunks. The DataSet then ‘manages’ the connection between the data and allows the user to edit, update, delete, append, or select portions of that data.

The DataSet is first and foremost a collection of table objects. These table objects can be imported from various and diverse data sources such as SQL Server, Oracle, XML files, and the like, or they can be entered programmatically or through a convenient User Interface (UI) and then added to the DataSet programmatically. The most useful methods are to Accept Changes, AcceptChanges, RejectChanges, Merge, Clone, a few functions for reading and writing XML and XML schema, and – most important of all- the GetChanges method, which gets a DataSet which contains all of the data changes made to the current one since it was loaded.

The table objects look like tables in a regular database, though they are virtual tables, which reside only in memory. The table objects have collections of DataColumns, DataRows, Constraints, DataRelations, Property Collections, DataRowView, and a PrimaryKey, which may be a collection of DataColumns.

 

DataTable Class Members

Constructors

Visibility

Constructor

Parameters

 

 

 

public

DataTable

( )

 

 

 

public

DataTable

( String tableName )

 

Properties

February 11, 2008

Visibility

Name

Value Type

Accessibility

 

 

 

 

public

CaseSensitive

Boolean

[ Get , Set ]

 

 

 

 

public

ChildRelations

DataRelationCollection

[ Get ]

 

 

 

 

public

Columns

DataColumnCollection

[ Get ]

 

 

 

 

public

Constraints

ConstraintCollection

[ Get ]

 

 

 

 

public

Container

IContainer

[ Get ]

 

 

 

 

public

DataSet

DataSet

[ Get ]

 

 

 

 

public

DefaultView

DataView

[ Get ]

 

 

 

 

public

DesignMode

Boolean

[ Get ]

 

 

 

 

public

DisplayExpression

String

[ Get , Set ]

 

 

 

 

public

ExtendedProperties

PropertyCollection

[ Get ]

 

 

 

 

public

HasErrors

Boolean

[ Get ]

 

 

 

 

public

Locale

CultureInfo

[ Get , Set ]

 

 

 

 

public

MinimumCapacity

Int32

[ Get , Set ]

 

 

 

 

public

Namespace

String

[ Get , Set ]

 

 

 

 

public

ParentRelations

DataRelationCollection

[ Get ]

 

 

 

 

public

Prefix

String

[ Get , Set ]

 

 

 

public

PrimaryKey

DataColumn

[ Get , Set ]

 

 

 

 

public

Rows

DataRowCollection

[ Get ]

 

 

 

 

public

Site

ISite

[ Get , Set ]

 

 

 

 

public

TableName

String

[ Get , Set ]

 

Methods

Visibility

Name

Parameters

Return Type

 

 

 

 

public

AcceptChanges

( )

Void

 

 

 

 

public

BeginInit

( )

Void

 

 

 

 

public

BeginLoadData

( )

Void

 

 

 

 

public

Clear

( )

Void

 

 

 

 

public

Clone

( )

DataTable

 

 

 

 

public

Compute

( String expression , String filter )

Object

 

 

 

 

public

Copy

( )

DataTable

 

 

 

 

public

EndInit

( )

Void

 

 

 

 

public

EndLoadData

( )

Void

 

 

 

 

public

GetChanges

( DataRowState rowStates )

DataTable

 

 

 

 

public

GetChanges

( )

DataTable

 

 

 

 

public

GetErrors

( )

DataRow

 

 

 

 

public

ImportRow

( DataRow row )

Void

 

 

 

 

public

LoadDataRow

( Object values , Boolean fAcceptChanges )

DataRow

 

 

 

 

public

NewRow

( )

DataRow

 

 

 

 

public

RejectChanges

( )

Void

 

 

 

 

public

Reset

( )

Void

 

 

 

 

public

Select

( String filterExpression , String sort , DataViewRowState recordStates )

DataRow

 

 

 

 

public

Select

( String filterExpression )

DataRow

 

 

 

 

public

Select

( )

DataRow

 

 

 

 

public

Select

( String filterExpression , String sort )

DataRow

 

 

 

 

public

ToString

( )

String

 

Events

Multicast

Name

Type

 

 

 

multicast

ColumnChanged

DataColumnChangeEventHandler

 

 

 

multicast

ColumnChanging

DataColumnChangeEventHandler

 

 

 

multicast

Disposed

EventHandler

 

 

 

multicast

RowChanged

DataRowChangeEventHandler

 

 

 

multicast

RowChanging

DataRowChangeEventHandler

 

 

 

multicast

RowDeleted

DataRowChangeEventHandler

 

 

 

multicast

RowDeleting

DataRowChangeEventHandler

Rows are added programmatically using the DataRows object:

 

Dim dr as DataRow=tblEmployee.NewRow()

dr(“dcFirstName”)=”Elmer”

dr(“dcLastName”)=”Fudd”

tblEmployee.Rows.Add(dr)

 

 

Resources

  • Tutorial: ADO.NET Populate a DataSet from a Database
This tutorial discusses populating a DataSet from a Database.
  • Tutorial: DataSet Vs. DataReader
This is an interesting resource that discusses DataSet and Datareader.