Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2006, 12:30 PM
Registered User
 
Join Date: Nov 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default drop down issues

I have an ASP page that I want to drop down lists populated from seperate SQL tables. The first is working fine...the second drop down doesn't even appear on the page...I am new to ASP so I am not really sure what to check...any suggestions are greatly appreciated.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<%
Dim conn,strstate,strjuris,SQL1,SQL2

set conn = Server.CreateObject("ADODB.Connection")
set strstate = Server.CreateObject("ADODB.Recordset")
set strjuris = Server.CreateObject("ADODB.Recordset")

conn.Open ("Provider=SQLOLEDB;User ID=sa;password=master;Initial Catalog=Inventory;Data Source=10.1.5.59")

SQL1 = ("select state from states")
SQL2 = ("SELECT JURISDICTION FROM JURISDICTIONS")

strstate.Open SQL1,conn
%>
<P> Select a State: </P>
<p>
  <select name="state" size="1">

    <%While Not strstate.EOF%>

    <option value="<%=strstate("state")%>"><%=strstate("state" )%></option>

    <%
strstate.MoveNext
wend

strstate.Close
strstate = Nothing
conn.Close
conn = Nothing
%>
  </select>
</p>
<p>
<%
strjuris.Open sql2,conn
%>
<P>Select a Jurisdiction: </P>
  <select name="jurisdiction" size="1">

  <%While Not strjuris.EOF%>

    <option value="<%=strjuris("jurisdiction")%>"><%=strjuris( "jurisdiction")%></option>

    <%
strjuris.MoveNext
wend

strjuris.Close
strjuris = Nothing
conn.Close
conn = Nothing
%>
  </select>
</p>
</body>
</html>


 
Old November 28th, 2006, 01:18 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Take a look at the source of the page. A lot of times you can see what the problem is there if nothing is showing on the page. You should at least be able to see an empty drop-down.

That's weird that the drop-down doesn't even appear.

 
Old December 18th, 2006, 09:27 AM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You have closed the connection and set it to nothing midway through the code.

Change to:

strstate.MoveNext
wend

strstate.Close
strstate = Nothing
%>
  </select>
</p>
<p>
<%
strjuris.Open sql2,conn

Regards,

Sean Anderson





Similar Threads
Thread Thread Starter Forum Replies Last Post
connection string issues, web.config file issues kaliaparijat ASP.NET 2.0 Professional 1 June 12th, 2008 08:07 AM
ASP - drop down box issues mhodges Classic ASP Professional 2 November 28th, 2006 07:23 PM
For-each issues hiskeyd XSLT 1 February 27th, 2006 08:01 PM
drop down list values based on another drop down noor ASP.NET 1.0 and 1.1 Basics 3 July 5th, 2005 09:57 AM
Populating Drop Down based on other drop down jeffbarclay Java Databases 1 November 7th, 2003 12:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.