473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

distinct value in dataview

hey all,
i have a dataview with a single column in it which contains duplicates. What
is the best way to eliminate the duplicates rows so i can turn this column
into the primary key?

thanks,
rodchar
Dec 10 '07 #1
3 8496
rodchar,

You will have to cycle through the rows, keeping track of the column
value for each row (a Dictionary<X, DataRowwould help, where X is the type
of the value in the column you are looking at) and then removing the row if
you find a duplicate.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:A1**********************************@microsof t.com...
hey all,
i have a dataview with a single column in it which contains duplicates.
What
is the best way to eliminate the duplicates rows so i can turn this column
into the primary key?

thanks,
rodchar

Dec 10 '07 #2
Also, are you trying to change this column into a primary key in the
underlying data source, or you just want to do it in the data table that the
data view is on? If the answer is the former, then you have to actually
remove those records from the database before you change the structure of
the table.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:u1**************@TK2MSFTNGP02.phx.gbl...
rodchar,

You will have to cycle through the rows, keeping track of the column
value for each row (a Dictionary<X, DataRowwould help, where X is the
type of the value in the column you are looking at) and then removing the
row if you find a duplicate.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:A1**********************************@microsof t.com...
>hey all,
i have a dataview with a single column in it which contains duplicates.
What
is the best way to eliminate the duplicates rows so i can turn this
column
into the primary key?

thanks,
rodchar


Dec 10 '07 #3
I just wanted to changed datatable and not the source. Also, I found
DataView.ToTable() function where you can specify distinct values, i thought
that was pretty neat.

thanks everyone for the help,
rod.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Also, are you trying to change this column into a primary key in the
underlying data source, or you just want to do it in the data table that the
data view is on? If the answer is the former, then you have to actually
remove those records from the database before you change the structure of
the table.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:u1**************@TK2MSFTNGP02.phx.gbl...
rodchar,

You will have to cycle through the rows, keeping track of the column
value for each row (a Dictionary<X, DataRowwould help, where X is the
type of the value in the column you are looking at) and then removing the
row if you find a duplicate.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:A1**********************************@microsof t.com...
hey all,
i have a dataview with a single column in it which contains duplicates.
What
is the best way to eliminate the duplicates rows so i can turn this
column
into the primary key?

thanks,
rodchar


Dec 10 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Karl Napp | last post by:
Hi NG, how to make a DataView show only selected COLUMNS? E.g: DataTable table // is already in memory and has two columns: "id" and "value" DataView view // should only show all rows from...
0
by: amrita | last post by:
hi i have 4 dropdownmenus and m binding them to diff columns of a dataview. want to show only distinct items in the dropdown menu ny filter in dataview to do this thanks in advance amrita
2
by: krishnan | last post by:
Dear all, In SQL Server 2000 , how to get distinct records sort by one field . Example SELECT DISTINCT A FROM tblTEST ORBER BY B Here, In Table
1
by: worldcyclist | last post by:
Hey folks, I am just getting into MySQL and have run into a problem with subqueries. I am running MySQL 4.0.21 and I am trying to CONCAT and I have no idea where I'm tripping up... The data...
0
by: Benny | last post by:
I am trying to figure out the best way to create a filtering user control. I have 3 fields I am using and therefore have 3 combobox's that all need to display distinct values. The resulting...
26
by: Michael R | last post by:
Hi all. This is an SQL question, so I hope this is the right place to ask it. I'm intersted in "compressing" a table to distinct values of a field or several fields, and having another field...
1
by: Synch | last post by:
I have a query that results in something like: field 1 field 2 red blue green black blue red orange black ...
5
by: zensunni | last post by:
Say we have a couple of tables like so: Departments_to_Employees department_id employee_id Employee employee_id I want to find how many employees the department with the maximum amount of...
42
by: polas | last post by:
Afternoon all, I have some code (which I thought was OK, but now appreciate is probably not by the standard) which contains int a; ...... if (a==NULL) { ....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.