473,394 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SQL query to populate dropdown

Sorry for cross-posting this to microsoft.public.inetserver.asp.db - I
didn't know if that group saw much action.

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.

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

Thanks,

Dave
Jun 27 '08 #1
2 3019
FatBear wrote:
Sorry for cross-posting this to microsoft.public.inetserver.asp.db -
The problem is: you did not crosspost it: you multiposted it. If you had
crossposted it by sending a single message to both groups, nobody would
have a problem with it.
I
didn't know if that group saw much action.
Posts there get as much attention as posts here

----canned response ---------------------------
Please do not multipost. This is definitely a database-related question
so .asp.db was the perfect group in which to post it. Posting it here as
well did not increase your chances of getting an answer (most of us
subscribe to both groups). On the contrary, if somebody had taken his
time
to answer it here, only to find that it was already resolved in the
other
group, that person may have been annoyed enough to ignore any future
posts
from you, thereby decreasing your chances of getting help in the future.

There are times when you will not be sure which group is most
appropriate,
and you will want to post a question to both groups. In that situation,
you
should use the cross-posting technique, rather than posting the same
message
multiple times. To crosspost, put a semicolon-delimited* list of the
newsgroups to which you wish to post in the To: header of your post and
post
it once. It, and any replies to it, will appear in all the newsgroups in
your list. So, if I reply in .asp.db, my reply will also appear here in
..asp.general.

* ... or whatever delimiter is recognized by your news client
------------------------------------------------------------------------
----------

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 27 '08 #2
Could you try this?

<%
sql = "SELECT division.name as divisionName, 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("divisionName")%>
<%rs.movenext%>
<%loop
rs.close%>

Jess

"FatBear" wrote:
Sorry for cross-posting this to microsoft.public.inetserver.asp.db - I
didn't know if that group saw much action.

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.

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

Thanks,

Dave
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gary T. | last post by:
I have a table called tbl_QuoteDetails QuoteNo Prim Key fkeyProductID foreign key Paneltype Length Price Another table called tbl_Product: ProductID Primary Key ProductName
5
by: JIM.H. | last post by:
Hello, I need to create a dropdown list that combines 3 fields form a table and show it a single item in dropdownlist. So List should have rows like Filed1-Filed2-Filed3. How can I do this?...
3
by: simon | last post by:
hello, i have a form where there are multiple dropdown lists that will all be populated from the same initial data query. i have a vb class defined to make the stored proc call and that returns a...
10
by: sandraz444 | last post by:
I have an expression in the query under my form to autofill the date under a certain condition but it wont write to the underlying table?? The date shows in the form but not the table. Does anyone...
0
by: Kay O'Keeffe | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp...
0
by: mharness | last post by:
Hello, Not sure if what I'm trying to do is possible or even a good idea. I have a datalist that can contain maybe 100 items shared among perhaps 20 accounts. Looks something like this: ...
2
by: mamun | last post by:
Hi All, The problem is as follows: I have a table from where I am getting consultant's name and populating the dropdown list control. But I want to populate the default one which I got it as...
1
by: fran7 | last post by:
Hi, Anyone know how to populate a dropdown list with data from database. I have an interface that generates the following code for names in my database. ..asp <%If Trim(rsCard("Author"))<>""...
0
kcdoell
by: kcdoell | last post by:
Hello: I have a form that I am using to help me display a query that I have built. On that form I have multiple combo boxes that I have called cobMonth, cobYear, cobWorkingRegion, etc......
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.