This includes a TableA and a TableB two DataTable objects in the myDataSet, and we access the DataTable contained in the DataSet through Dataset.tables properties. For example, you can access A TableA object by using this statement: mydataset.tables["A". But the datatablecollection indexer (in fact dataset.tables is datatablecollection type) can only get a DataTable object from the user and cannot be set.
mydataset.tables["A"] = mydataset.tables["B"]; Bad syntax
Such a statement can be compiled with an error. So how do we reset a TableA? Re-declare a DataTable object, and then copy TableB to the new DataTable object.
The structure and data in the newtable are the same as the TableB in this case. But how do we give newtable copy to TableA? Try the following code
Newtable.tablename = "A";
MyDataSet.Tables.Remove ("A");
MYDATASET.TABLES.ADD (newtable):
Remove the original TableA from the dataset, set the newtable name to the TableA name, and add newtable to the dataset so we can get a new TableA
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.