removing mulitple entries from datatable
-
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 -
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 StewartHi, 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 -
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 StewartUse 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
-
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