Populer Topics

DataTable

A dataset is made up of a collection of table relationship and constrains to represent the tables in the dataset.

The datatable class is a member of File System.Data namespace within the .net framework class library we can create and use a DataTable independently as a member of dataset.

DataTable object can also be use in other .net framework object include data view. We can create parent child relationship between tables using one more related columns in the tables.

We create relationship between datatable object using a data relation object written the related child or parent row of a particular.DataTable class provide following property.

Property Description
TableName It will return the name of the table. We can also set the name of the table.
Rows.Count It will returns no of rows in datatable object.
Colums.Count  It will returns total no of columns in datatable.
PrimaryKey It will returns all primary key associated with first table as an array.
Constrains It return the constrains associated with particular parameter table as constrains collection.

DataTable provides following method.

Method Description
Clear() Clear all the data inside all DataTable.
AcceptChanges() Allow as to accept changes after calling this method changes are reflected back to database table.
WriteXml() I Allow us to write xml file and copy it into database.
NewRow() Allow us to create new black DataRow object.
Select() Allow us to select group of data from table.
Rows.Add() Allow us to add new row to should be object of datarow.