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 8883417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:48:27+00:00 2026-06-14T20:48:27+00:00

My Datatable 1 (dtOutput) Format (termid,faultid,faultdesc,faulttime,devicetype) My Datatable 2 (dtOpenEvent) Format (termid,faultid) I want

  • 0

My Datatable 1 (dtOutput) Format (termid,faultid,faultdesc,faulttime,devicetype)

My Datatable 2 (dtOpenEvent) Format (termid,faultid)

I want to retrieve those values which are present in Datatable 2 but not in Datatable 1…based on two columns (termid,faultid) no table have primary keys.

I Searched on net and find code which return diff between two data table…

Now how can i retrieve column values from it ? either in another data table or in string variable

Code :-

DataTable dtOpenEvent;
dtOpenEvent = Generix.getOpenEvents(ref Connection);
DataTable dtOutput;
dtOutput = Generix.getFeedData(ref Connection);
var matched = from table1 in dtOpenEvent.AsEnumerable()
              join table2 in dtOutput.AsEnumerable() on table1.Field<string>("ATM") equals table2.Field<string>("termid")
              where table1.Field<int>("Event") == table2.Field<int>("faultid") 
              select table1;
var missing = from table1 in dtOpenEvent.AsEnumerable()
              where !matched.Contains(table1)
              select table1;
  • 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-14T20:48:29+00:00Added an answer on June 14, 2026 at 8:48 pm

    you can remove all of the columns in dt1 and then do except.

    like this:
    var diff =dt2.AsEnumerable().Except(dt1.AsEnumerable(), DataRowComparer.Default);

    full example:

                DataTable dt1 = new DataTable();
                DataTable dt2 = new DataTable();
    
                dt1.Columns.Add("termid", typeof(Int32));
                dt1.Columns.Add("faultid", typeof(Int32));
                dt1.Columns.Add("faultdesc");
                dt2.Columns.Add("termid", typeof(Int32));
                dt2.Columns.Add("faultid", typeof(Int32));
    
                dt1.Rows.Add(1,2,"desc");
                dt1.Rows.Add(3, 4, "desc");
                dt1.Rows.Add(5, 6, "desc");
                dt2.Rows.Add(1, 2);
                dt2.Rows.Add(3, 4);
                dt2.Rows.Add(7, 8);
    
                dt1.Columns.Remove("faultdesc");
                var diff =dt2.AsEnumerable().Except(dt1.AsEnumerable(), DataRowComparer.Default);
    
                foreach (var row in diff)
                {
                    Console.WriteLine(row["termid"] + " " + row["faultid"]); //prints 7 8
                }  
    

    or instead of removing columns you can select them through linq or dataview like this:

            var view = new DataView(dt1);
            DataTable dt3 = view.ToTable(true, "termid", "faultid");    
    

    modified example:

                DataTable dt1 = new DataTable();
                DataTable dt2 = new DataTable();
    
                dt1.Columns.Add("termid", typeof(Int32));
                dt1.Columns.Add("faultid", typeof(Int32));
                dt1.Columns.Add("faultdesc");
                dt2.Columns.Add("termid", typeof(Int32));
                dt2.Columns.Add("faultid", typeof(Int32));
    
                dt1.Rows.Add(1,2,"desc");
                dt1.Rows.Add(3, 4, "desc");
                dt1.Rows.Add(5, 6, "desc");
                dt2.Rows.Add(1, 2);
                dt2.Rows.Add(3, 4);
                dt2.Rows.Add(7, 8);
    
                var view = new DataView(dt1);
                DataTable dt3 = view.ToTable(true, "termid", "faultid");
                var diff =dt2.AsEnumerable().Except(dt3.AsEnumerable(), DataRowComparer.Default);
    
                foreach (var row in diff)
                {
                    Console.WriteLine(row["termid"] + " " + row["faultid"]);
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my DataTable has over 1000 columns and I want to display values on the
In DataTable i have this format mm/dd/yyyy hh:mm:ss AM I want to change format
My Datatable contains a list of values, of which certain are checked. How can
Datatable contain some values like 0.0,10000.00,54678.94 . am getting that values using for loop
Got datatable with Id, parentId, description. It is a relationial table structure. I want
I have a datatable which contains yearly data saved. e.g. dtDate Value 2010-01-01 00:00:00.000
I have a datatable where I want to change the color of a cell
I have a DataTable which is generated from .xls table. I would like to
I want to store each Datatable Column in a string variable so that i
My DataTable Contains 17 columns, among which i am retrieving 3 columns. For Instance,

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.