Batch Processing SQL statement to retrieve multiple tables and fill Dataset

Source: Internet
Author: User

If you use a batch processing SQL statement to retrieve multiple tables and fill in dataset, the first table is named by the table name specified to the fill method. The following table is named by adding a number starting from 1 and increasing to 1 to the table name specified for the fill method. For exampleCode:

'Visual basic
Dim da As sqldataadapter = new sqldataadapter ("select * from MERs MERS; select * from orders;", myconnection)
Dim ds as dataset = new dataset ()
Da. Fill (DS, "MERs ")

// C #
Sqldataadapter da = new sqldataadapter ("select * from MERs MERS; select * from orders;", myconnection );
Dataset DS = new dataset ();
Da. Fill (DS, "MERs ");

 

After filling in the dataset, you can easily change the tablename attribute of the customers1 table to "orders ". However, subsequent filling will cause the "MERs" table to be refilled, while the "orders" table will be ignored and another "customers1" table will be created. To remedy this situation, create a ableablemapping, map "customers1" to "orders", and create other table mappings for other tables. For example:

'Visual basic
Dim da As sqldataadapter = new sqldataadapter ("select * from MERs MERS; select * from orders;", myconnection)
Da. tablemappings. Add ("customers1", "orders ")
Dim ds as dataset = new dataset ()
Da. Fill (DS, "MERs ")

// C #
Sqldataadapter da = new sqldataadapter ("select * from MERs MERS; select * from orders;", myconnection );
Da. tablemappings. Add ("customers1", "orders ");
Dataset DS = new dataset ();
Da. Fill (DS, "MERs ");

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.