Solved

Classic ASP nesting inside of a loop

Posted on 2010-08-20
3
413 Views
Last Modified: 2012-06-27
I have list of possible travel locations in my db table for vacation packages we offer. I'm using a SELECT DISTINCT (SELECT DISTINCT Category FROM dbo.VacPckg) to weed out duplicate location categories.

My Results as expected:
Asia
Canada
Caribbean
Hawaii
Pacific Northwest
etc....

Here is where I need help. I want add "Europe" into the above results in ABC order but "Europe" is not in the db table. Is it possible to add it inside of a loop/wend? Is there another method I should try?

Preferred Results:
Asia
Canada
Caribbean
EUROPE
Hawaii
Pacific Northwest



<!--#include virtual="/Connections/myConString.asp" -->

<%
Set strObj = Server.CreateObject ("ADODB.Command")
strObj.ActiveConnection = MYl_STRING
SQL = "SELECT DISTINCT Category FROM dbo.VacPckg" 
strObj.Prepared = true
strObj.CommandText =  sql
Set rsCategory = strObj.Execute
rsCategory_numRows = 0
%>

<ul>
<% while not rsCategory.EOF %>

<li><a href="vacpkg.asp?ref=<%=rsCategory(0)%>"><%=rsCategory(0)%></a></li>
<% rsCategory.MoveNext
wend %> 
        
</ul>

<%
rsCategory.Close()
Set rsCategory = Nothing
%>

Open in new window




0
Comment
Question by:swaggerking
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
mcv22 earned 250 total points
Comment Utility
Try this:


SELECT DISTINCT Category FROM dbo.VacPckg
UNION
SELECT 'Europe' AS Catgory

Open in new window

0
 
LVL 12

Expert Comment

by:mcv22
Comment Utility
Category ^typo
0
 

Author Closing Comment

by:swaggerking
Comment Utility
It worked. Thanks!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now