Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


If statement

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,77
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> If statement
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 If statement - 6/1/2001 11:24:35 AM   
  neilld

 

Posts: 13
Score: 0
Joined: 5/23/2001
From: USA
Status: offline
I have an asp page that selects names out of a column in a database to place them in a drop down box. Problem is that the information is placed by quaters. so the name is in the column multiple times. How do I write the statement to only select the name once and not mulitple times.

Here is the code I have so far:

<select name="selection">
<% do while not ors.eof %>
<option><% =ors.fields ("selection").value %>
</option></font>
<% ors.movenext
loop
'dbobj.close
'set dbobj=nothing%></select>
 
 
Post #: 1
 
 Re: If statement - 6/1/2001 11:25:52 AM   
  rahul27

 

Posts: 19
Score: 0
Joined: 5/23/2001
From: India
Status: offline
First of all is much faster to pass a SQL statemne then looping through and testing for values.
And if you want just one occurance of an item use DistinctRow: So if there are 20 records and 10 of them are "Smith" and 5 are "Jones" and 5 are "Rayfield" then you will only see 3 items in your dropdown. One Smith, one jones and one Rayfield.

SQLString = "Select DistinctRow Field1 From yourTable Where something = Somethingelse"

then create a loop where is puts just those 3 records in your Selection box

Set ors.open(SQLString)

<% do while not ors.eof %>
<option><% =ors.fields("Field1").value %>
</option></font>
<% ors.movenext
loop

Not sure what kind of database you are opening so my "Set" statement may not be right.

(in reply to neilld)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> If statement Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts