|
 |
asp_databases thread: Problematic DISTINCT statement
Message #1 by "Sarah Margolis" <sarahmargolis@m...> on Sat, 16 Jun 2001 07:14:49 -0700
|
|
Hello,
I'm trying to populate a drop-down box using the DISTINCT option.
When I run this code I get a drop-down box that looks like it has the right
number of options, but all the values are empty. What could be wrong?
Thanks.
<%
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 %>
Best,
Sarah
Message #2 by "Ted Lontine" <tedster07@q...> on Sat, 16 Jun 2001 15:13:47 -0600
|
|
Sarah:
Try encasing your option value tag in quote, thus the line after the IF statement would
read:
<option value="<%=RSWinery("Winery")%>"><%= RSWinery("Winery")%></option>
instead of
<option value=<%=RSWinery("Winery")%>><%= RSWinery("Winery") %></option>
Maybe?
Regards,
Ted
----- Original Message -----
From: "Sarah Margolis" <sarahmargolis@m...>
To: "ASP Databases" <asp_databases@p...>
Sent: Saturday, June 16, 2001 8:14 AM
Subject: [asp_databases] Problematic DISTINCT statement
> Hello,
>
> I'm trying to populate a drop-down box using the DISTINCT option.
> When I run this code I get a drop-down box that looks like it has the right
> number of options, but all the values are empty. What could be wrong?
> Thanks.
>
> <%
> 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 %>
>
> Best,
> Sarah
>
>
>
|
|
 |