博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
将数据库的内容放到下拉列表中(转)
阅读量:2517 次
发布时间:2019-05-11

本文共 2004 字,大约阅读时间需要 6 分钟。

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") %> ("first_name") %> ("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
%>

' Continue until we get to the end of the recordset.
Do While Not objRS.EOF
' For each record we create a option tag and set
it's value to the employee id
' The text we set to the employees first name
combined with a space and then their last name
%>
">objRS.Fields("first_name") & " " & objRS.Fields("last_name") %
>
' Get next record
objRS.MoveNext
Loop
%>
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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10294527/viewspace-124475/

你可能感兴趣的文章
【2020-3-21】Mac安装Homebrew慢,解决办法
查看>>
influxdb 命令行输出时间为 yyyy-MM-dd HH:mm:ss(年月日时分秒)的方法
查看>>
已知子网掩码,确定ip地址范围
查看>>
判断时间或者数字是否连续
查看>>
docker-daemon.json各配置详解
查看>>
Docker(一)使用阿里云容器镜像服务
查看>>
Docker(三) 构建镜像
查看>>
FFmpeg 是如何实现多态的?
查看>>
FFmpeg 源码分析 - avcodec_send_packet 和 avcodec_receive_frame
查看>>
FFmpeg 新旧版本编码 API 的区别
查看>>
RecyclerView 源码深入解析——绘制流程、缓存机制、动画等
查看>>
Android 面试题整理总结(一)Java 基础
查看>>
Android 面试题整理总结(二)Java 集合
查看>>
学习笔记_vnpy实战培训day02
查看>>
学习笔记_vnpy实战培训day03
查看>>
VNPY- VnTrader基本使用
查看>>
VNPY - CTA策略模块策略开发
查看>>
VNPY - 事件引擎
查看>>
MongoDB基本语法和操作入门
查看>>
学习笔记_vnpy实战培训day04_作业
查看>>