Wrox Programmer Forums
|
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 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 6th, 2007, 09:12 AM
Authorized User
 
Join Date: Apr 2007
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP classic looping twice

Hi.

I have a code to loop data into a puldown box. can not figure out why in the world the results are appearing TWICE for every row!

Code:
<%
LETTER = request.querystring("LETTER")


SQL ="SELECT at_access.user_ID, customer.custcode, customer.custname FROM customer, at_access WHERE customer.custcode LIKE '" & LETTER & "%'"
Rs.Open sql, Conn

%>



        <table border="0" cellspacing="0" cellpadding="10" align="center">
                <tr>
                <td align="center" colspan="2" class="subhead">

<form action="myaccount/oddlist_ataccess/oddlist_ataccess.asp?search=" method="get">
<input type="hidden" name="repcode" value="<%= Rs("user_ID") %>">

<%
                If LETTER < "0" Then
            %>
<b>EXCESS INVENTORY BARGAINS:
</b><BR>
<b>Please Select A Letter For A Customer!
</b>
            <% Else %>
<b>EXCESS INVENTORY BARGAINS:
</b><BR>
<select NAME="Search">
    <%
    Do While Not rs.EOF
        %>

            <OPTION value='<%=Rs("custcode")%>'> <%=Rs("custcode")%> = <%=Rs("custname")%></OPTION>
<% rs.MoveNext
loop
%>
</select>
<BR><BR>
<input TYPE="submit" VALUE="Excess Inventory Bargains" style="width: 300px">
</form>

</td>
</tr>
</table>
<%
end if
conn.close
%>

all my customers are getting listed TWICE:

SSKEMP
SSKEMP
IFED
IFED
PLUMBINGSUPPLY
PLUMBINGSUPPLY

ETC...

database is perfect. No doubles. any clue?

 
Old September 6th, 2007, 12:59 PM
Authorized User
 
Join Date: Sep 2007
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

Your sql statement is pulling data from two tables...you are probably missing another join condition in your where statement...to eliminate duplicate data.

Have you tried running your sql statement in sql query analyzer...to see if your results contain two rows (if so then you know its not a problem with your asp code)

http://mynameissteve.com
 
Old September 6th, 2007, 01:00 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default


Hi Melkin!!

Your asp code is fine,only problem is with the query
SQL ="SELECT at_access.user_ID, customer.custcode, customer.custname FROM customer, at_access WHERE customer.custcode LIKE '" & LETTER & "%'"

Reason-ur qury is cross join,so resulting multiple results
 use inner join
Hope this will help you


Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Classic ab289 Classic ASP Basics 6 March 10th, 2008 02:53 PM
Converting Classic Asp to Asp.Net 2.0 vikaspatyal ASP.NET 2.0 Professional 2 October 7th, 2007 06:33 PM
asp.net vs classic asp "URGENT" naeem_ul_hussan Classic ASP Professional 1 August 1st, 2007 03:14 PM
classic asp with asp.net on same iis bostonrose .NET Framework 2.0 6 January 10th, 2007 12:38 PM
ASP classic function lucian Classic ASP Professional 2 May 4th, 2005 12:03 PM





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