Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 7th, 2006, 08:15 PM
SoC SoC is offline
Authorized User
 
Join Date: Jul 2004
Location: , , .
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default vbscript version of SQL 'SELECT DISTINCT'

Howdy,

I am querying our Active Directory to built a phone list. I wanted to select a distinct list of locations, but it looks like MS's ADSI SQL dialect does not support 'SELECT DISTINCT'.

So I'm guessing I'll have to build a distinct list on the client side with vbscript, but my vb knowledge is very limited. Can someone point me in the right direction?

Do I need to create an array or something? Or does vbscript have another way of manipulating the recordset to pull out only distinct values form a particular field?

Thanks

Reply With Quote
  #2 (permalink)  
Old February 8th, 2006, 03:16 AM
SoC SoC is offline
Authorized User
 
Join Date: Jul 2004
Location: , , .
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorted.

Managed to use a dictionary object - stored the unique records in it. Problem is I'm sure it's a lot slower than a SQL Select Distinct equivalent, cos my solution is happening on the client side:

Code:
set objD = CreateObject("Scripting.Dictionary")

while not myRS.EOF
    myString = myRS.Fields("physicalDeliveryOfficeName")
    if not objD.Exists (myString) then
        objD.Add myString, myString
    end if
   myRS.MoveNext
wend
Then to display the unique results in a select box:

<select name="sel1">
<%
myResults = objD.Items
for i = 0 to objD.Count - 1%>
<option><%=myResults(i)%></option>
<%
next
objD.RemoveAll
set objD = nothing
%>
</select>



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Distinct kirkmc Access 13 July 13th, 2006 01:26 PM
Select Distinct kirkmc Excel VBA 3 May 5th, 2006 07:55 PM
Select Distinct? hugh@kmcnetwork.com SQL Language 5 November 5th, 2005 09:58 AM
Distinct SELECT DISTINCT question... EndEffect Classic ASP Databases 4 August 18th, 2005 08:53 AM
select distinct bmains ADO.NET 0 April 8th, 2004 02:50 PM



All times are GMT -4. The time now is 07:57 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.