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. Web Development
  3. ASP.NET
  4. removing mulitple entries from datatable

removing mulitple entries from datatable

Scheduled Pinned Locked Moved ASP.NET
databasequestion
4 Posts 3 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.
  • P Offline
    P Offline
    playout
    wrote on last edited by
    #1

    Hi, I have a datatable called dtEmployeeData. In the datatable the Employee's name can sometimes be in there more then once(I get this data from a sql database). Now I can't change my select query, to bring back the employee name only once, as the his name is allowed to be in the gridview more then once(due to transaction history). What I want to do now is, is to select only the name from that datatable, and only show his name once in a dropdownlist. I use this dropdownlist to show all the employee names, and the name must only appear once. How would I do this? Here is my code I have so far: Dim dtEmployeeData As DataTable = New DataTable() dtEmployeeData = BO.getData() drpSort.DataValueField = "EmployeeName" drpSort.DataTextField = "EmployeeName" drpSort.DataSource = dtEmployeeData Using this code, I get: Abraham Bennie John John John Peter Stewart I want to have the following: Abraham Bennie John Peter Stewart

    V V 2 Replies Last reply
    0
    • P playout

      Hi, I have a datatable called dtEmployeeData. In the datatable the Employee's name can sometimes be in there more then once(I get this data from a sql database). Now I can't change my select query, to bring back the employee name only once, as the his name is allowed to be in the gridview more then once(due to transaction history). What I want to do now is, is to select only the name from that datatable, and only show his name once in a dropdownlist. I use this dropdownlist to show all the employee names, and the name must only appear once. How would I do this? Here is my code I have so far: Dim dtEmployeeData As DataTable = New DataTable() dtEmployeeData = BO.getData() drpSort.DataValueField = "EmployeeName" drpSort.DataTextField = "EmployeeName" drpSort.DataSource = dtEmployeeData Using this code, I get: Abraham Bennie John John John Peter Stewart I want to have the following: Abraham Bennie John Peter Stewart

      V Offline
      V Offline
      Vipin d
      wrote on last edited by
      #2

      Hi, i think u can add some constraint to this datatable...here u can use UNIQUE constarint to employee name..... Please search for Adding constarint to a datatable.. i hope that ll help u. happy programming

      All I ever wanted is what others have....
      CrazySanker

      1 Reply Last reply
      0
      • P playout

        Hi, I have a datatable called dtEmployeeData. In the datatable the Employee's name can sometimes be in there more then once(I get this data from a sql database). Now I can't change my select query, to bring back the employee name only once, as the his name is allowed to be in the gridview more then once(due to transaction history). What I want to do now is, is to select only the name from that datatable, and only show his name once in a dropdownlist. I use this dropdownlist to show all the employee names, and the name must only appear once. How would I do this? Here is my code I have so far: Dim dtEmployeeData As DataTable = New DataTable() dtEmployeeData = BO.getData() drpSort.DataValueField = "EmployeeName" drpSort.DataTextField = "EmployeeName" drpSort.DataSource = dtEmployeeData Using this code, I get: Abraham Bennie John John John Peter Stewart I want to have the following: Abraham Bennie John Peter Stewart

        V Offline
        V Offline
        Venkatesh Mookkan
        wrote on last edited by
        #3

        Use DISTINCT statement in your SELECT query. Eg: SELECT DISTINCT emp_name FROM emp_master The above query would give you the unique names.

        Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

        P 1 Reply Last reply
        0
        • V Venkatesh Mookkan

          Use DISTINCT statement in your SELECT query. Eg: SELECT DISTINCT emp_name FROM emp_master The above query would give you the unique names.

          Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

          P Offline
          P Offline
          playout
          wrote on last edited by
          #4

          Hi Venkatesh, I need to select from a datatable, not the sql database. I need to do something like a groupBy in the datatable, on a certain column. Any idea how to do that?

          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