ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 将数据库的内容放到下拉列表中(转)

将数据库的内容放到下拉列表中(转)

原创 Linux操作系统 作者:jcszjswkzhou 时间:2019-03-10 08:57:05 0 删除 编辑
<%
Dim objDC, objRS

' Create and establish data connection
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.ConnectionTimeout = 15
objDC.CommandTimeout = 30

'Use this line to use Access
'objDC.Open "DBQ=" & Server.MapPath("database.mdb") & ";Driver=
{Microsoft Access Driver
(*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20;", "username", "pas
sword"

'Our SQL Server code - use above line to use sample on your server
objDC.Open Application("SQLConnString"), Application("SQLUsername"),
Application("SQLPassword")


' Create recordset and retrieve values using the open connection
Set objRS = Server.CreateObject("ADODB.Recordset")
' Opening record set with a forward-only cursor (the 0) and in read-
only mode (the 1)

' If a request for a specific id comes in, then do it o/w just show
pulldown
If Len(Request.QueryString("id")) <> 0 Then
' request record for requested id
objRS.Open "SELECT * FROM sample WHERE id=" &
Request.QueryString("id"), objDC, 0, 1
' Show selected record
If Not objRS.EOF Then
objRS.MoveFirst
%>














ID Number First Name Last Name Month's Sales
<%=
objRS.Fields("id") %>
<%= objRS.Fields
("first_name") %>
<%= objRS.Fields
("last_name") %>
<%=
objRS.Fields("sales") %>

<%
End If
objRS.Close
End If

objRS.Open "sample", objDC, 0, 1
' Loop through recordset and display results
If Not objRS.EOF Then
objRS.MoveFirst
' the form below calls this file only this time with an id
in the QueryString
%>





<%
End If

' Close Data Access Objects and free DB variables
objRS.Close
Set objRS = Nothing
objDC.Close
Set objDC = Nothing
%>


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-124475/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-08-29

  • 博文量
    2968
  • 访问量
    2189955