473,382 Members | 1,692 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,382 software developers and data experts.

query dataset for distinct records

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
5 4704
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
But where would I put that select statement to pull it out of an already
populated database?
Nov 21 '05 #3
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Not Me | last post by:
Hi, Having a table with some duplicate ID's (different data tho), how can I return the list but with only one record from each ID? Would this be using the first() function and grouping? ...
2
by: Justin Koivisto | last post by:
In PHP, I do the following (pseudo code for clarity)... Query: SELECT distinct(web_contacts.zip) FROM web_contacts WHERE web_contacts.zip <> '' Query: SELECT DISTINCT(contacts.zip) FROM contacts...
16
by: tyrfboard | last post by:
I've been searching for awhile now on how to remove duplicates from a table within an Access db and have found plenty of articles on finding or deleting duplicates. All I want to do is remove them...
2
by: Allen Anderson | last post by:
Hi, I'm trying to design contact (names and addresses) tables in an Access database. Some of the contacts represent vendors, some are board members of the organization, some are donors, some...
6
by: issac | last post by:
Hi folks Im trying to do a simple query involving the distinct keyword and an access 2000 db, but have been frittering with it for amost and hour and a half and I cant make it work. This is...
2
by: jmarr02s | last post by:
I don't know what I am doing wrong I get duplicate records when I query Here is my SQL query code: SELECT Utilization_T.Facid, Utilization_T.Year, Utilization_T.Beds, Utilization_T.LicBeds,...
5
by: justanothernewbie804 | last post by:
hi all. I have a dataset and would like to do something like "select distinct field1, field2 from fields" against the dataset. I do not have the option of creating a new database table and...
7
by: nofear | last post by:
I have a table with 2 fields where one has duplicates and the other does not something like this: ID field1 field2 1 A A 2 A B 3 A C...
3
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
In Visual Studio 2005, I have my DataSet filled with several static tables (they might get changed weekly, but that's about it). With one of these tables in the DataSet, is it possible to select...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.