Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 December 21st, 2004, 11:21 AM
Registered User
 
Join Date: Dec 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Find Dictinct Value In DataTable

Hi

Is there a way to find distinct values of a column from
DataTable other than running a loop?

So far this what I did:
1. create a new table and added a new column
2. create a new view from existing table and sort it
3. loop thru the column, find a new value and add it to the new table.

Please do not suggest me to edit the SQL query that fills the datatable.
The filled database is already a summary of millions of records, I want to avoid the 2nd trip to the SQL server.
 
Old December 21st, 2004, 11:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Does a DISTINCT help?

Select DISTINCT COL_NAME from TABLE_NAME.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old December 21st, 2004, 01:33 PM
Registered User
 
Join Date: Dec 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Sorry I don't quite understand.
Here is my query:

SELECT company_id, produc_id, sum(amount)
FROM purchase
WHERE customer_id = 123
GROUP BY company_id, product_id;

This is of course a simplified version of the actual query.
I execute the query and store them in my DataSet

Now, I want to get a distinct company_id, how do I do it
from ASP.NET. rather than execute the 2nd Query something like
SELECT distinct company_id
FROM purchase
WHERE customer_id = 123

Because I will need to find distinct value of other columns as well.


 
Old December 13th, 2005, 09:08 AM
Registered User
 
Join Date: Dec 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can allways do SQL-Ansi commands in your DataTables if you like.
That way you can save your SqlServer

peace
 
Old December 13th, 2005, 09:12 AM
Registered User
 
Join Date: Dec 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can save your sql server by using sql-ansi like commands directly in your application datatables.

are you using visual studio 2005?

peace





Similar Threads
Thread Thread Starter Forum Replies Last Post
Datatable Limno .NET Framework 1.x 0 May 28th, 2008 02:37 PM
Find a Row in Datatable everest C# 1 August 1st, 2007 03:01 PM
Open Word Doc from Access - find, find next save donaldmaloney Access VBA 1 May 25th, 2005 11:09 AM
Create a find and a find and replace in VB.NET snowy0 VB How-To 0 January 26th, 2004 07:03 PM





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