470,591 Members | 1,484 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

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 8380
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Karl Napp | last post: by
reply views Thread by amrita | last post: by
1 post views Thread by worldcyclist | last post: by
reply views Thread by Benny | last post: by
42 posts views Thread by polas | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.