Asp. The conversion between DataTable and dataset in net example _ practical Tips

Source: Internet
Author: User
The dataset contains multiple DataTable, and a constraint relationship between the DataTable.
If your data does not need to do relational mapping, it is more efficient to use DataTable directly. If there is a relationship query that needs to be 1:n or n:m, populate the corresponding DataTable in the dataset, and then use the relational query data.

DataSet data source you can think of it as a database, and a DataTable is a table in a database.

To add a DataTable to a dataset:

When a DataTable is encountered in a project and cannot be converted directly to a dataset,

You can start new.
We can just get the new DataSet C and fill it out.
DataSet ds = new DataSet ();
DataTable dt= New DataTable ("Customers");

Ds. Tables.add (DT);

To read a DataTable in a dataset:

Dt=ds. tables[0];//Specify table No. 0

Dt=ds. tables["Customers"];//specify table with table named "Customers"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.