query dataset for distinct records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
But where would I put that select statement to pull it out of an already
populated database?
 
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.aspx?scid=kb;EN-US;325684


hope that helps..
Imran.
 
thank you for the tips.

Imran Koradia said:
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.aspx?scid=kb;EN-US;325684


hope that helps..
Imran.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

array in dataset 4
Debugging Immediate Window 6
modifying my db 4
Table validating 5
Selecting Dataset records 4
exposing datasets 2
import text getting null 14
Filter records in DataSet 2

Back
Top