Re: SQL Query - Populate Drop Down



"Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx> wrote in news:e
$a3H8vnIHA.6064@xxxxxxxxxxxxxxxxxxxx:

FatBear wrote:
Hi All,

I'm very new to ASP and am now working on an existing site that is
written in ASP. I'm trying to populate a dropdown box with the
results of a query. There is current code that does this but it
populates with team name whereas I want division name.

The database is set up as:
League - connected to - Division - connected to Team

I want to be able to have someone choose a league and then on the next
page populate a dropdown with all the divisions in that league.

Here is the working code.

<%sql = "SELECT division.name, team.id, team.name as team, [team-
division].season
from (([division-league]
inner join division on division.id = [division-league].division)
inner join [team-division] on [team-division].division = division.id)
inner join team on team.id = [team-division].team
where league=" & thisleague
cmd.CommandText = sql
rs.Open cmd, , 1,1
do while not rs.eof
seasonid = rs("season")%>
<option value="<%=rs("id")%>"><%=rs("team")%> (<%=rs
("name")%>)
<%rs.movenext%>
<%loop
rs.close%>

I have tried many things but I think just changing the query as
follows, should work but have had no success.

What are the symptoms that tell you that you have had no success? Don't
forget, we have no access to your data so we can't run this code
ourselves to see what symptoms you are getting.

<%sql = "SELECT division.name, division.id from [division-league],
division
where [division.league].id = division.id
and league=" & thisleague


You should supply a few rows of sample data (in tabular format),
followed by desired results from that sample data (also in tabular
format), followed by the bad results this query is giving you.


Hi Bob,

Thanks for your response and I promise I won't crosspost anymore. Here
are more details regarding the problem:

1. It is an access database.
2. The problem is that no data appears in the dropdown. The box is there
but there are no values in it.
3. Here are the tables I'm using:

LEAGUE
ID Name
145 Monday night Shinny - JD

DIVISION
ID Name
176 Team A
177 Team B
178 Team C
179 Team D
180 Team E

DIVISION-LEAGUE
ID Division League
176 177 145
177 178 145
178 179 145
179 180 145
180 181 145

<%sql = "SELECT division.name, division.id from [division-league],
division
where [division.league].id = division.id
and division.league=" & thisleague

thisleague is a variable that equates to 145 in this case.

Please let me know if you need anything else.

Thanks,

Dave








.



Relevant Pages

  • Re: SQL Query - Populate Drop Down
    ... League - connected to - Division - connected to Team ... next page populate a dropdown with all the divisions in that league. ... You should supply a few rows of sample data, ...
    (microsoft.public.inetserver.asp.db)
  • Re: SQL Query - Populate Drop Down
    ... I'm very new to ASP and am now working on an existing site that is ... League - connected to - Division - connected to Team ... page populate a dropdown with all the divisions in that league. ...
    (microsoft.public.inetserver.asp.db)
  • SQL Query - Populate Drop Down
    ... I'm very new to ASP and am now working on an existing site that is ... League - connected to - Division - connected to Team ... page populate a dropdown with all the divisions in that league. ...
    (microsoft.public.inetserver.asp.db)
  • Re: WebPart Postback
    ... Dropdown_Load event to populate the dropdown from the existing list ... In the Load event populate the Dataset and put the dataset in a Session ... Create a new button event handler, populate the datagrid from the ... Dim oSite As SPSite ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: Populating text boxes with macros in dropdowns
    ... Code such as the following can be used to populate a formfield with an ... autotext entry that corresponds to an item selected from a dropdown type ... items from dropdowns in a list of contents that will then populate text ... in other areas of the document with information relevant to the selection ...
    (microsoft.public.word.vba.general)

Loading