Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Probematic DISTINCT statement


Message #1 by "Sarah Margolis" <sarahmargolis@m...> on Fri, 15 Jun 2001 10:33:59 -0700
I'm trying to populate a drop-down box with the names of different wineries.

Why isn't this working?



<%

Dim Connection

Dim RSWinery

Dim SQL

Set Connection = Server.CreateObject("ADODB.Connection")

Connection.Open "wine.dsn"

SQL = "SELECT Distinct Winery from Wineries"

Set RSWinery = Connection.Execute(SQL)%>



 <select name="Winery" size="1">

     <option value="" selected>Select a winery</option>

    <%  Do While NOT RSWinery.EOF %>

    <% If RSWinery("Winery") <> "" Then %>

   <option value=<%=RSWinery("Winery")%>><%= RSWinery("Winery") %></option>

            <% End If %>

            <% RSWinery.MoveNext

    Loop  %>

</select>

    <%RSWinery.close

   Set RSWinery = nothing %>



    <% Connection.Close

   Set Connection = Nothing %>



Thanks.



Best,

Sarah



Message #2 by "Wakeley, Stuart" <Stuart.Wakeley@c...> on Fri, 15 Jun 2001 14:28:05 -0400
what error message are you getting?





Message #3 by =?iso-8859-1?Q?H=E5kan_Frennesson?= <hakan@c...> on Fri, 15 Jun 2001 21:14:28 +0200
Hi!



You have two >> in your second option value statement....maybe thatīs

why..or else we need to see the error message to be able to help.





Hakan



-----Original Message-----

From: Sarah Margolis [mailto:sarahmargolis@m...]

Sent: den 15 juni 2001 19:34

To: ASP Databases

Subject: [asp_databases] Probematic DISTINCT statement





I'm trying to populate a drop-down box with the names of different wineries.

Why isn't this working?



<%

Dim Connection

Dim RSWinery

Dim SQL

Set Connection = Server.CreateObject("ADODB.Connection")

Connection.Open "wine.dsn"

SQL = "SELECT Distinct Winery from Wineries"

Set RSWinery = Connection.Execute(SQL)%>



 <select name="Winery" size="1">

     <option value="" selected>Select a winery</option>

    <%  Do While NOT RSWinery.EOF %>

    <% If RSWinery("Winery") <> "" Then %>

   <option value=<%=RSWinery("Winery")%>><%= RSWinery("Winery") %></option>

            <% End If %>

            <% RSWinery.MoveNext

    Loop  %>

</select>

    <%RSWinery.close

   Set RSWinery = nothing %>



    <% Connection.Close

   Set Connection = Nothing %>



Thanks.



Best,

Sarah




  Return to Index