compare two datatable schema using LINQ. RRS feed

  • General discussion

  • I have to compare two datatable schema using LINQ.

    For eg: datatable dt1 contains actual columns 


    and datatable dt2 may contains  extra columns since it is reading from an excel file.


    I want to compare dt2 with dt1 and delete the unwanted columns X,Y,Z from dt2.

    Any help is appreciated.




    Tuesday, November 2, 2010 9:11 AM

All replies

  • I doubt if you could do that with Excel and actually change the columns in database.

    However, if you work with Entity Framework, you could change the storage db schema at runtime. Please check this entry for more detail information:

    Best regards

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Thursday, November 4, 2010 6:33 AM
  • Thanks for your reply.

    I dont want to change the storage DB Schema.,It is fixed.

    I need to insert the records from datatable to the database.

    For that I take Db columns from ist datatable and the excel file columns to 2nd table.

    But the excel file column may have unwanted/extra columns.

    So that I want to compare the 2nd datable columns to the 1st datatable and delete the extra columns from 1st datatable

    Friday, November 5, 2010 10:56 AM