I HAVE TWO STORED PROCEDURES SUMMARY1 AND SUMMARY 2 AND GET THE STORED PROCEDURES DATA INTO TWO DIFFERENT DATA TABLE DT1 AND DT2 IN C#

Royce Roy

Total Post:149

Points:1043
Posted by  Royce Roy
C# 
C#
 870  View(s)
Ratings:
Rate this:
Hi Expert!

I want to get data in third data table dt3 in particular format like

if dt1 table are as --

name |   m1 |   m2   |   m3   |
abc  |   12 |   4    |   8    |
dcd  |   1  |   5    |   7    | 
dt 2 table data are as -

name |   m1 |   m2   |   m3   |
abc  |   5  |   5    |   5    |
dcd  |   5  |   5    |   5    | 
both data table have same number of columns with same column name .

i want result in dt3 in this format

name |   m1     |   m2   |   m3   |
abc  |   12/5   |   4/5  |   8/5  |
dcd  |   1/5    |   5/5  |   7/5  |
and bind data table dt3 data to a gridview.

Thanks in advance.

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: I have two stored procedures summary1 and summary 2 and get the stored procedures data into two different data table dt1 and dt2 in c#

    Hi Royec!


    You may use Linq for this,

    var dt3 = from p in dt1.AsEnumerable()
                       join q in dt2.AsEnumerable() on p.Field<string>("name") equals q.Field<string>("name") into UP
                       from q in UP.DefaultIfEmpty()
                       select new
                       {
                            name = p.Field<string>("name"),
                            m1 = p.Field<string>("m1") + "/" + q.Field<string>("m1"),
                            m2 = p.Field<string>("m2") + "/" + q.Field<string>("m2"),
                            m3 = p.Field<string>("m3") + "/" + q.Field<string>("m3")
                       };

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!