DataSet object can be regarded as a (Catch), it can retain the data found from the database, and even temporarily store the entire database
DataSet is the representation of data in memory
The connection between the DataSet object and the data source occurs very briefly. We disconnect from the data source immediately after obtaining the data. We wait until the data is modified or needs to be No connection will be established until the data in the data source is manipulated.
The DataSet object contains a set of DataTable objects and DataRelation objects.
The DataTable object is an important object of the DataSet. One, representing a relational data table in memory
TableName: Get or set the name of the table
DataSet: Point out which DataSet the table belongs to
Rows (Add, InsertAt, Remove, RemoveAt): DataRow object collection, which represents the collection of rows of this table
Columns: Data Columns object collection, which represents the collection of columns of this table
Example:
DataSetds = new DataSet();
DataTable student = new DataTable("Student");
DataColumn sno = new DataColumn( "Sno");
sno.DataType = typeof(string);
sno.MaxLength = 8;
DataColumn sname = new DataColumn("Sname");
sno.DataType = typeof(string);
sno.MaxLength = 8;
student.Columns.Add(sno);
student.Columns .Add(sname);
ds.Tables.Add(student);
DataRow drl = student.NewRow();
drl["Sno"] = " 0125";
drl["Sname"] = "Li Shuang";
student.Rows.Add(drl);
DataRow dr2 = student.NewRow();
drl["Sno"] = "0125x";
drl["Sname"] = "xLi Shuang";
student.Rows.Add(dr2);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
The above is the detailed content of How to analyze DataSet objects and use them. For more information, please follow other related articles on the PHP Chinese website!