Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-21-2006, 01:12 PM   PM User | #1
Seanus
New Coder

 
Join Date: Mar 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Seanus is an unknown quantity at this point
Drop Down list from database

HI guys,

I am starting to go a bit mad - please help. I have got a database with about 40 schoolnames that I am trying to display in a drop down but it only shows the first 20 or so records. I have been through it all about 100 times but don't know asp well enough to see where it is not working. I have pasted the code below and would like to thank you in advance:

<form action="send_email.asp" method=post>
<select name="schoolname">

<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rswedweb 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Dim schoolcont

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Wedweb.mdb")

'Create an ADO recordset object
Set rswedweb = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
'strSQL = "select schoolcont.schoolname FROM schoolcont ORDER BY schoolname"
'strSQL = "select schoolcont.schoolname, schoolcont.supported, schoolcont.email FROM schoolcont where schoolcont.supported = 'Y' ORDER BY schoolname"
strSQL = "select * FROM schoolcont"

'Open the recordset with the SQL query
rswedweb.Open strSQL, adoCon

Do While not rswedweb.EOF
schoolname = rswedweb("schoolname")
if Not IsNull(schoolname) then %>


<%end if%>

<option value="<%Response.Write rswedweb("schoolname") & ""%></option>
<%Response.Write rswedweb ("schoolname")%>
<%rswedweb.MoveNext
Loop



'Reset server objects
rswedweb.Close
Set rswedweb = Nothing
Set adoCon = Nothing
%>
</select>
</form>
</td>
Seanus is offline   Reply With Quote
Old 04-23-2006, 01:24 AM   PM User | #2
BaldEagle
Regular Coder

 
Join Date: Apr 2005
Location: Lisbon, CT
Posts: 339
Thanks: 0
Thanked 0 Times in 0 Posts
BaldEagle is an unknown quantity at this point
Make this change:

Code:
<option value="<%=rswedweb("schoolname")%>"><%=rswedweb("schoolname")%></option>
or
Code:
<option value="<%=schoolname%>"><%=schoolname%></option>
BaldEagle
BaldEagle is offline   Reply With Quote
Old 04-24-2006, 11:15 AM   PM User | #3
Seanus
New Coder

 
Join Date: Mar 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Seanus is an unknown quantity at this point
Thanks a lot! This has worked. Much appreciated.

Seanus is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:01 AM.


Advertisement
Log in to turn off these ads.