DataSet
Represents the cache of data in memory.
Property
Tables gets a collection of tables that are contained in the DataSet.
Ds. tables["SJXX"]
DataTable
Represents a table of data in memory.
Public properties
Columns gets the collection of columns that belong to the table.
The dataset obtains the dataset to which this table belongs.
DefaultView gets a custom view of a table that might include a filtered view or cursor location.
PrimaryKey Gets or sets an array of columns that act as the primary key of the datasheet.
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 of a column in a DataTable.
Copy Code code as follows:
Examples of common operations for DataTable and dataset
Create DataSet
DataSet ds = new DataSet ();
Creating 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);
Adding 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");