Subscribe to Subscribers

Online Members

baskar
More...

Resources » Code Snippets » ADO.NET

Using DataTableMapping to name different tables in a DataSet


Posted Date:     Category: ADO.NET    
Author: Member Level: Gold    Points: 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...

Feedbacks      

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.


    Next Resource: Pass NULL as a Parameter Value to SQLParameter
    Previous Resource: Binding Local Client Report Definition(RDLC) File with ReportViewer Control
    Return to Resources
    Post New Resource
    Category: ADO.NET


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    (No tags found.)

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2013 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.