By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,703 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,703 IT Pros & Developers. It's quick & easy.

query dataset for distinct records

P: n/a
Hey all,
I have an asp.net app.
I'm trying to load a drop-down list from a dataset, but I only want the
unique records of the particular field, is there a way I can do this?

thanks,
rodchar
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Your query should look like:

SELECT DISTINCT ColumnName FROM TableName

This will return the unique records for that particular column from your
table.

hope that helps..
Imran.

"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:D2**********************************@microsof t.com...
Hey all,
I have an asp.net app.
I'm trying to load a drop-down list from a dataset, but I only want the
unique records of the particular field, is there a way I can do this?

thanks,
rodchar

Nov 21 '05 #2

P: n/a
But where would I put that select statement to pull it out of an already
populated database?
Nov 21 '05 #3

P: n/a
oops..sorry. Towards the end of the day in office..you know how that goes :)

Anyway, there is no direct way of filtering out distinct values from a
datatable in a dataset. Here are a couple of options you have:

1. You could create a new DataColumn and create a unique constraint on it
and then copy the contents from your original data column to this new
column. It'll throw up an error when you try to enter duplicate values. You
can suppress the error so that you don't end up with a chain of exceptions.

2. here's another solution:
http://support.microsoft.com/default...b;EN-US;325684
hope that helps..
Imran.

"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
But where would I put that select statement to pull it out of an already
populated database?

Nov 21 '05 #4

P: n/a
thank you for the tips.

"Imran Koradia" wrote:
oops..sorry. Towards the end of the day in office..you know how that goes :)

Anyway, there is no direct way of filtering out distinct values from a
datatable in a dataset. Here are a couple of options you have:

1. You could create a new DataColumn and create a unique constraint on it
and then copy the contents from your original data column to this new
column. It'll throw up an error when you try to enter duplicate values. You
can suppress the error so that you don't end up with a chain of exceptions.

2. here's another solution:
http://support.microsoft.com/default...b;EN-US;325684
hope that helps..
Imran.

"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
But where would I put that select statement to pull it out of an already
populated database?


Nov 21 '05 #5

P: n/a
Rodchar,

In addition to Imran,

When you have an already filled datatable you can use this routine that I
once made to get those values you want.

http://groups.google.com/groups?selm...TNGP15.phx.gbl

I hope this helps?

Cor
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.