网络编程
位置:首页>> 网络编程>> Asp编程>> 如何把数据库记录显示到列表框里去?

如何把数据库记录显示到列表框里去?

 来源:asp之家 发布时间:2009-11-06 13:48:00 

标签:数据库,列表

我见朋友可以把数据库的记录显示到列表框里去,挺实用,也想做一个。怎么做啊?

这简单,代码和说明如下:

dblist.asp

<html>
<head>
<TITLE>列表框显示记录 - aspxhome.com</TITLE>
</head><body bgcolor="#FFFFFF">
<% 
myDSN="DSN=Student;uid=student;pwd=magic"
mySQL="select digicamera from digicameras where AU_ID<100"
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
' 把一个数据库域做为一个列表框显示
if  rstemp.eof then
  response.write "噢,找不到记录!<br>"
  response.write mySQL
  conntemp.close
  set conntemp=nothing
  response.end      
end if
%>
<form action="dblistrespond.asp" method="post">
<Select name="digicameratype">
<%
do  until rstemp.eof %>
  <option> <%=RStemp(0)%> </option>
<%
  rstemp.movenext
loop
' 抓取所有数据
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
%>
<input type="submit" value="选择">
</Select></form>
</body>
</html>
dblistrespond.asp
<html>
<body bgcolor="#FFFFFF">
<%
my_digicamera=request.form("digicameratype")
%>
您的选择是: <%=my_digicamera%>
</body>
</html>

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com