Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8973323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:25:10+00:00 2026-06-15T18:25:10+00:00

i have 2 datatables tables which have the same columns but with different data

  • 0

i have 2 datatables tables which have the same columns but with different data and some times there are rows the share the same ID

i want to join those to table where ID of some row in table2 doesn’t exist in table1

so if i the following tables
ID Name
1  A
2  B
3  C

ID Name
5  D
1  A
2  B
3  C

the from joining would be

ID Name
1  A
2  B
3  C
5  D

here is what i tried

 Dim q = From e In tbl1.AsEnumerable Join r In tbl2.AsEnumerable On e.Field(Of Integer)("id") Equals r.Field(Of Integer)("id")

but no idea on how do i get this to a datatable

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:25:11+00:00Added an answer on June 15, 2026 at 6:25 pm

    LINQ is not all that good in working with DataTable but you could do something like this:

    Dim diff = tbl2.AsEnumerable().Except(tbl1.AsEnumerable(), New DataRowComparer())
    
    Dim tbl = tbl1.Copy()
    For Each dataRow As DataRow In diff
        tbl.ImportRow(dataRow)
    Next
    

    You need to create an IEqualityComparer to define how to compare DataRows. I decided to compare only their Id value but you could compare every column in a similar manner:

    Public Class DataRowComparer
        Implements IEqualityComparer(Of DataRow)
    
        Public Function Equals(ByVal x As DataRow, ByVal y As DataRow) As Boolean Implements IEqualityComparer(Of DataRow).Equals
            Return CInt(x("Id")) = CInt(y("Id"))
        End Function
    
        Public Function GetHashCode(ByVal obj As DataRow) As Integer Implements IEqualityComparer(Of DataRow).GetHashCode
            Return CInt(obj("Id")).GetHashCode()
        End Function
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two data tables which have a primary key column in common but
i have two data tables with the same structure the first one has one
I have the data table from the jquery plugin dataTables (http://datatables.net/) that I want
I have a DataTable which I want to save to a SQLite Database Table.
Hi I have a datatables based table that holds data. I need to be
I have a JSR-168 portlet application in which some portlets use a JSF dataTable.
I am using jQuery datatables to display some data. Each row has an edit
I created a simple solution for expandable columns/rows with rich:datatable and rich:column, which is
I have one WCF which i have used in my project. Now i want
I am using DataTables for my tables. I am having a few columns with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.