DataSet.merge and DataTable operation tips

xiaoxiao2021-04-10  381

Some of the operations of DataTable, such as: Want to puminate a DataRow from a DataTable to generate another DataTable, or adjust the sort in the DataTable, let me have a headache for a while. Today, I found a heavy load in the MERGE method when I was bored in the DataSet member table in the boring, and the Merge method was DataSet.Merge (DataRow []), and the effect is to merge DATAROW [] directly into the current DataSet. I have started testing. The first problem will extract AID> 100 in the DTA table of the DTA table from the DTA table of the DSB to the DTA. As follows: DSB.Merge (DSA.Tables ["DTA"]. Select ("AID> 100", "")); After running, the effect is more satisfactory. A table of DTA in the DSB, the record is the record of the AID> 100.

The second problem, modify the DTA record in DTA in DTA to the AID DESC as follows: DSA.Merge (DSA.Tables ["DTA"]. Select ("", "AID DESC"); result There is no reaction, and the data is changed. It didn't think of a way, just after a copy of the DTA table COPY. As follows: DataTable dtacopy = dsa.tables ["DTA"]. Copy (); DSA.Tables.Remove ("DTA"); DSA.Merge (DTACOPY.SELECT ("", "AID DESC"); The results of the operation are desired, and the records in the DTA table have been sorted according to the requirements.

This is more suitable for table data packet operations within DataSet. It's just that the Copy Remove Merge that is like this will not know too much.

转载请注明原文地址:https://www.9cbs.com/read-133247.html

New Post(0)