Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 10th, 2004, 02:43 PM
Authorized User
Join Date: Aug 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unique values from a dataset

Goodday all,

Having a difficult time figuring this out. I am working on a windows form with an access back end.

I'd like to get the unique values from a single column in a datatable in a dataset. There are ways that I can pull back rows of information but I only want those values from a single column and only the unique ones.

I have tried the expression function for a datatable but unique or distinct are not recognized words. Nor am I able to build a dataview based soley on the column that I would like, where I would loop to find the specific unique values.

Any ideas?


Old September 10th, 2004, 04:27 PM
Friend of Wrox
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post

Are you saying currently you have a table that doesn't have a primary
key or unique value in one of the fields.
If this is true try adding a new field with AutoNum to increment automatically.

Or you want a unique value coming from a expression / calculation from other field values. If this is what you want you can do is
set an expression from a control/text box prop. in a Form using default value.

Or in a form, under design view, try to create a function/vba code in event tab properties like After Update. This could make you customize
your values to be unique.

Hope this helps.

Old September 22nd, 2004, 07:53 AM
Authorized User
Join Date: Aug 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks John, but I guess I was not clear in my message.

In SQL the thing to do would be to say Select Distinct but I just don't want to go back to the data base.

The solution I came up with is to loop through the data and test each item against the previous item in an ordered set this way i can test for uniqueness in the column.

Thanks for the reply.

Now if you have any clear way of updating a database I would love to hear it. But I put that in another post somewhere.


Old September 27th, 2004, 12:17 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

Why reinvent the "distinct" functionality by rewriting when you can just use the logic that already exists in the database?

Similar Threads
Thread Thread Starter Forum Replies Last Post
DataSet Column with Unique Constrain Problem niceFEPF C# 5 July 31st, 2009 07:04 PM
How to Generate Unique values for IDs mphare XSLT 7 November 6th, 2008 12:20 PM
Dataset repeated values Narts C# 1 November 23rd, 2007 10:31 AM
including unique values from a range into a combo Kaustav Excel VBA 0 November 6th, 2006 09:17 AM
load values into the dataset from the xml dhol General .NET 2 December 31st, 2004 06:37 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.