How to analyze DataSet objects and use them

王林
Release: 2023-05-16 11:55:06
forward
1103 people have browsed it
Concept of DataSet object:

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.

DataTable objects and their use.

The DataTable object is an important object of the DataSet. One, representing a relational data table in memory

Common properties of DataTable objects

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!