Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Remove Duplicates in Datatable

Remove Duplicates in Datatable

Scheduled Pinned Locked Moved C#
question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kibromg
    wrote on last edited by
    #1

    I have a various tables which gets activated as a user selects an option.I want to poulate the results in a datatable and check they are not duplicate data from each table.My datatable should contain a dataonly once no duplicates. How do i go about that? Is there a function that checks the data before writing it to datatable so that it cant duplicate? Please advice Thanks and regards

    C C A 3 Replies Last reply
    0
    • K kibromg

      I have a various tables which gets activated as a user selects an option.I want to poulate the results in a datatable and check they are not duplicate data from each table.My datatable should contain a dataonly once no duplicates. How do i go about that? Is there a function that checks the data before writing it to datatable so that it cant duplicate? Please advice Thanks and regards

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Not really, your database should have keys set so that it won't accept duplicates. The other way is to write a select to see if the data exists. Finally, you can insert with a stored proc that first checks if the data exists, and only inserts if it doesn't.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • K kibromg

        I have a various tables which gets activated as a user selects an option.I want to poulate the results in a datatable and check they are not duplicate data from each table.My datatable should contain a dataonly once no duplicates. How do i go about that? Is there a function that checks the data before writing it to datatable so that it cant duplicate? Please advice Thanks and regards

        C Offline
        C Offline
        Chintan Desai
        wrote on last edited by
        #3

        Every table must have primary key and the Domain of each column must matches with one another to get the correct type of data in a column of the datatable.Load 1st row from i(Option selected) table to common datatable, check whether that rows is exists in common datatble,if it is then dont add the row else add them and proceed further with next row in i table.:rose:

        Regards Chintan www.visharadsoft.com (Nothing is so purify as KNOWLEDGE)

        K 1 Reply Last reply
        0
        • C Chintan Desai

          Every table must have primary key and the Domain of each column must matches with one another to get the correct type of data in a column of the datatable.Load 1st row from i(Option selected) table to common datatable, check whether that rows is exists in common datatble,if it is then dont add the row else add them and proceed further with next row in i table.:rose:

          Regards Chintan www.visharadsoft.com (Nothing is so purify as KNOWLEDGE)

          K Offline
          K Offline
          kibromg
          wrote on last edited by
          #4

          THANK YOU ALL YOUR HELP IS VERY GREAT.

          1 Reply Last reply
          0
          • K kibromg

            I have a various tables which gets activated as a user selects an option.I want to poulate the results in a datatable and check they are not duplicate data from each table.My datatable should contain a dataonly once no duplicates. How do i go about that? Is there a function that checks the data before writing it to datatable so that it cant duplicate? Please advice Thanks and regards

            A Offline
            A Offline
            AFSEKI
            wrote on last edited by
            #5

            Have a look at DataColumn.Unique property.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups