DataSet
Represents the cache of data in memory.
Property
Tables gets the collection of tables contained in the DataSet.
Ds. tables["SJXX"]
DataTable
Represents a table of in-memory data.
Public properties
Columns gets the collection of columns that belong to the table.
The dataset gets the dataset to which this table belongs.
DefaultView gets a custom view of a table that might include a filtered view or cursor position.
PrimaryKey Gets or sets an array of columns that act as the primary key for the data table.
Rows gets the collection of rows that belong to the table.
TableName Gets or sets the name of the DataTable.
DataRow
Represents a row of data in a DataTable
row["Index"]
DataColumn
Represents the schema for a column in a DataTable.
Examples of common operations for DataTable and dataset
Create a DataSet
DataSet ds = new DataSet ();
Create a DataTable
DataTable dt = new DataTable ();
Dt. Columns.Add ("id", Type.GetType ("System.Int32"));
Dt. columns["id"]. AutoIncrement = true;
Dt. Columns.Add ("Name", Type.GetType ("System.String"));
Insert Row
DataRow dw1 = dt. NewRow ();
dw1["name"] = "test1";
Dt. Rows.Add (DW1);
DataRow dw2 = dt. NewRow ();
dw2["name"] = "test2";
Dt. Rows.insertat (dw2,0);
Add a DataTable to a dataset
Ds. Tables.add (DT);
Query in DataTable
DataTable dt = new DataTable ();
DataRow dr[] = dt. Select ("1 = 1");
DataTable Update
DataTable dt = (DataTable) httpcontext.current.cache["Mycache"];
datarow[] dr = dt. Select ("1 = 1");
if (Dr. Length > 0)
{
dr[0]["colname"] = "colvalue";
}
Statistics
Object o = Dt.compute ("SUM (col_name)", "1=1");
(Transferred from Saysay,looklook, detections)
Goto: DataSet, DataTable, DataRow, DataColumn differences and usages