Completely Free .NET word API

Resources » Code Snippets » ADO.NET

Using DataTableMapping to name different tables in a DataSet

Updated: Category: ADO.NET
Author: Member Level: GoldPoints: 7

When you use batch SQL statement to retrieve multiple tables and fill a DataSet, the first table is named using the table name specified to the Fill method and subsequent tables are named using the name specified to the Fill method plus one. To avoid this situation we can create a DataTableMapping that maps "Employees1" to "Salary".

SqlDataAdapter dataAd = new SqlDataAdapter("SELECT * FROM Employees; SELECT * FROM Salary;", myConnection);
dataAd .TableMappings.Add("Employees1", "Salary");
DataSet ds = new DataSet();
dataAd .Fill(ds, "Employees");

Did you like this resource? Share it with your friends and show your love!

Responses to "Using DataTableMapping to name different tables in a DataSet"

No responses found. Be the first to respond...


Post Comment:

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)

    Type the numbers and letters shown on the left.

    Submit Article     Return to Article Index
    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India