Tips for dataset. Merge and datatable operations

Source: Internet
Author: User

Some operations on datatable, such as generating another able from a certain datarow in a able, or adjusting the sort (SORT) method in the datatable, have a headache for me for a while.
Today, when reading the dataset member table in sdk2.0, I found that one of the merge methods is dataset. merge (datarow []) is used to directly merge datarow [] into the current dataset.
I started a test.
The first problem is to extract records of aid> 100 from the DTA table of DSA to the DTA of DSB.
The statement is as follows:
DSB. Merge (DSA. Tables ["DTA"]. Select ("aid> 100 ",""));
After running, the results are satisfactory. In DSB, there is another DTA table, and the records in the table are records of aid> 100.

The second problem is to change the record sorting method in the DTA table in DSA to aid DESC.
The statement is as follows:
DSA. Merge (DSA. Tables ["DTA"]. Select ("", "aid DESC "));
There was no response, and no data changes at all. I can't find a solution, but I just copied the DTA table and made it again.
The statement is as follows:
Datatable dtacopy = DSA. Tables ["DTA"]. Copy ();
DSA. Tables. Remove ("DTA ");
DSA. Merge (dtacopy. Select ("", "aid DESC "));
The running result is exactly what you want. Records in the DTA table have been sorted as required.

This method is suitable for grouping table data in dataset. I just don't know if the back-and-forth copy remove merge will be too costly.

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.