This is a mirror of official site: http://jasper-net.blogspot.com/

How do you do an outer join with DataTables in .NET 2.0 ?

| Monday, September 13, 2010
Last week, I had to join two DataTables together using an outer join.  Seems easy right?  And if you're thinking, PIECE OF CAKE!!!!!!!!!!!!  Just requery the DB.  Or mabye you're thinking to yourself, just use LINQ.  HHHHHMMMMM I would LOVE to use those things but the problem is I'm tied to .NET 2.0 and unfortunately the data is already in an XML file and I'm not able to requery the db again.  DOH!  If you're shrugging your shoulders......now you know where I was last week!

Well, as my boss Shane would say, just use brute force.  Yup, after googling/binging around, I realized, besides requerying db, which I already mentioned wasn't feasible, I would have to do it myself.  Ok, no big deal right.....take a deep breath and check this out, it's not that bad.

I'm dumbing down the problem to it's utter essance, but the deal is I had to read two DataSets from different XML files (which I've blogged someting about last week) then perform an "a right outer join" on two of the tables.  In other words, I wanted all the rows from Table A (which has an ordering column), join it to Table B but making sure to include all the rows from the second Table B.  Ok, ok,TECHNICALLY this is considered in SQL, a RIGHT outer join, but if you flip the tables around you get a left outer join.

Read more: PC Henry

Posted via email from .NET Info

0 comments: