• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

How to avoid duplicated when merging two tables

I want to merge two tables but I found duplicated IDs in result table dt30.   How to avoid?
Any comment or instruction will be appreciated!!

         //DataTable dt30 = new DataTable();
            //DataTable dt60 = new DataTable();
            //dt30 = ReportsUtility.GetFormExceptionsList(LeftIDs, RightIDs, POHData.DAOs.Reports.DQ.DqFormExceptionsDao.ReportTypes.ThirtyDayExceptions);
            //dt60 = ReportsUtility.GetFormExceptionsList(LeftIDs, RightIDs, POHData.DAOs.Reports.DQ.DqFormExceptionsDao.ReportTypes.SixtyDayExceptions);
1 Solution
Jacques Bourgeois (James Burger)PresidentCommented:
Your GetFormExceptionList method probably calls Fill to fill the tables. This retrieves the field names and the data, but nothing more.

Have it call FillSchema before calling Fill so that the DataTable knows which field is the PrimaryKey.

You might also look the documentation for the following overload of Merge: http://msdn.microsoft.com/en-us/library/wtk78t63(v=vs.80).aspx
jssong2000Author Commented:
Thank you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now