|
Subroutines Query2List by Charles
Carroll
Subroutines can save you having to repeat blocks of code and
can optionally be placed in separate files and included when needed, thus making your
pages not appear to have lots of code in-line.
filename=/learn/test/subdblist.asp
<html><head>
<TITLE>subdblist.asp</TITLE>
</head><body bgcolor="#FFFFFF">
<form>
<%
theDSN="DSN=student;uid=student;pwd=magic"
call query2list("city","publishers","cy",theDSN,"Rockville")
call query2list("state", "publishers","st",theDSN,"MD")
call query2list("zip", "publishers","zp",theDSN,"20851")
%>
</form>
<!--#include virtual="/learn/test/subdblist.inc"-->
</body></html>
The include file lib_dblist.asp looks like:
filename=/learn/test/lib_dblist.asp
<%sub query2list(myquery,myname,myDSN)
dim conntemp, rstemp
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
set rstemp=conntemp.execute(myquery)
%>
<Select name="<%=myname%>">
<%
do while not rstemp.eof
thisfield=trim(RStemp(0))
if isnull(thisfield) or thisfield="" then
' ignore
else
response.write "<option>" & thisfield & "</option>"
end if
rstemp.movenext
loop
%>
</select>
<%rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
end sub%>
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|