9 Replies - 9828 Views - Last Post: 23 August 2011 - 07:38 AM Rate Topic: -----

#1 bikashvb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-August 11

Problem Left Join of Two DataTable into One Datatable

Posted 23 August 2011 - 06:31 AM

My 1st DataTable TableA

      Item       Place
  -------------------------
      ItemA      PlaceA
      ItemC      PlaceC

My 2nd DataTable TableB

      Item       Status
---------------------------
      ItemB     
      ItemC      Complete

Out Put DataTable will Like 

     Item      Place       Status
-------------------------------------
     ItemA     PlaceA  
     ItemB                 Complete
     ItemC     PlaceC      Complete

I am Using the following Code

        Dim DT_A As DataTable
        DT_A = TableA.Copy()

        Dim DT_B As DataTable
        DT_B = TableB.Copy()

        DT_A.Merge(DT_B)/>

But I am not Getting the Proper Output

Plaese Help

Thanks in Advance





Is This A Good Question/Topic? 0
  • +

Replies To: Problem Left Join of Two DataTable into One Datatable

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14764
  • View blog
  • Posts: 59,022
  • Joined: 12-June 08

Re: Problem Left Join of Two DataTable into One Datatable

Posted 23 August 2011 - 06:45 AM

What is "proper output" defined as?
Was This Post Helpful? 0
  • +
  • -

#3 bikashvb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-August 11

Re: Problem Left Join of Two DataTable into One Datatable

Posted 23 August 2011 - 06:48 AM

Proper Out Means

the Actual Output what I Need the desired DataTable

Thanks

This post has been edited by bikashvb: 23 August 2011 - 06:55 AM

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14764
  • View blog
  • Posts: 59,022
  • Joined: 12-June 08

Re: Problem Left Join of Two DataTable into One Datatable

Posted 23 August 2011 - 06:51 AM

Are you going to tell us what that is so I can begin to decipher your cryptic post?

When you only say "it's not working" that doesn't help people to help you. How is it not working? What actions is it doing? What actions SHOULD it be doing? Is there an exception? If so what does the exception say and what line is it occurring on? Be descriptive of what the problem is, the code involved, and the outcome you are looking for.
Was This Post Helpful? 0
  • +
  • -

#5 bikashvb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-August 11

Re: Problem Left Join of Two DataTable into One Datatable

Posted 23 August 2011 - 07:03 AM

I have got My 1st DataTable TableA from Database which is given below

Item Place
-------------------------
ItemA PlaceA
ItemC PlaceC

I have got My 2nd DataTable TableB from Database which is given below

Item Status
---------------------------
ItemB
ItemC Complete

The New Data Table will Look Like Below

Item Place Status
-------------------------------------
ItemA PlaceA
ItemB Complete
ItemC PlaceC Complete

I am Using the following Code

Dim DT_A As DataTable
DT_A = TableA.Copy()

Dim DT_B As DataTable
DT_B = TableB.Copy()

DT_A.Merge(DT_B)

I am Getting Like below
Item Place Status
-------------------------------------
ItemA PlaceA
ItemB Complete
ItemC PlaceC
ItemC Complete


But I am not Getting the Like Below Data Table

Item Place Status
-------------------------------------
ItemA PlaceA
ItemB Complete
ItemC PlaceC Complete

Please Help.What is the Main Problem and Whats the Solution

Thanks in Advance
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14764
  • View blog
  • Posts: 59,022
  • Joined: 12-June 08

Re: Problem Left Join of Two DataTable into One Datatable

Posted 23 August 2011 - 07:08 AM

Why not write a join statement in sql? A basic left join would get you want you want.
Was This Post Helpful? 0
  • +
  • -

#7 bikashvb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-August 11

Re: Problem Left Join of Two DataTable into One Datatable

Posted 23 August 2011 - 07:19 AM

How to write the left join with two data Table and store the result into another data table


Thanks
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14764
  • View blog
  • Posts: 59,022
  • Joined: 12-June 08

Re: Problem Left Join of Two DataTable into One Datatable

Posted 23 August 2011 - 07:23 AM

Pretty straight forward SQL statement.

select <mix of columns from your tables>
from <table 1>
left join <table 2> on <column(s) you want to join on>
where <where conditions>



http://msdn.microsof...fice.12%29.aspx
Was This Post Helpful? 0
  • +
  • -

#9 bikashvb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-August 11

Re: Problem Left Join of Two DataTable into One Datatable

Posted 23 August 2011 - 07:35 AM

Not Table I want to Mean DataTable

How to Join Two DataTable and How to Store The Out put into Another DataTable
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14764
  • View blog
  • Posts: 59,022
  • Joined: 12-June 08

Re: Problem Left Join of Two DataTable into One Datatable

Posted 23 August 2011 - 07:38 AM

Ah, use LINQ?

http://msdn.microsof...y/bb311040.aspx
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1