这篇文章给大家介绍动态服务器页面怎样循环读取数据库记录,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
% @ LANguage=' VBscript ' CodePage=' 936 ' %
%会话。代码页=936%
!DOCTYPEhtmlPUBLIC '-//W3C//DTDXHTML 1.0 transitional//EN '
http://www .w3。org/TR/XHTML 1/DTD/XHTML 1-过渡性。' DTD '
html xmlns=' http://www。w3。org/1999/XHTML '
头
meta http-equiv=' Content-Type ' Content=' text/html;charset=gb2312 '
元名称=“视口”内容=“宽度=设备宽度,初始比例=1.0,
最小规模=1.0,最大规模=1.0,用户可扩展=否'
titleScale3DC2018Read/title
/head
身体
%
Setconn=服务器CreateObject('ADODB .连接)
“提供商=微软.喷气机。OLEDB.4.0数据源=
服务器. MapPath('数据库\ Scale 3 CiP . MDB’)
conn.Openconnstr
Setrs=服务器CreateObject('ADODB .记录集)
sql='从customorderbyiddesc中选择*
卢比.Opensql,conn,1,1
与此同时
%
tableborder=1
tr
td%=rs('keyid')%/td
td%=rs('IPAddress')%/td
td%=rs('面积)%/td
td%=rs('LoginTime')%/td
/tr
%
rs.movenext
环
rs.close()
setrs=无
conn.close()
setconn=无
%
/table
/body写入数据库
% @ LANguage=' VBscript ' CodePage=' 936 ' %
%会话。代码页=936%
!-# include file=' web \ \ global。Inc -
!DOCTYPEhtmlPUBLICnb
sp;"-//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=gb2312" >
<!--meta http-equiv="Content-Type" content="text/html; charset=utf-8" /-->
<meta name="viewport" content="width=device-width, initial-scale=1.0,
minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" >
<title>Scale3DC2018</title>
</head>
<body>
<%
dim keyid
keyid = request.QueryString("keyid")
if IsEmpty(keyid) then
Response.End()
end if
%>
<%'创建连接对象
set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")
DBPath =Server.MapPath("database/Scale3DCIP.mdb")
dbconnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
%>
IP 地址
<%
dim ipStr
ipStr = getip()
'Response.Redirect("http://api.map.baidu.com/location/ip?ip=
"+getip()+"&ak=v6j7koi0ywtlK1RxZR47KSvkmmSzqIdn&coor=bd09ll")
%>
<%'创建记录对象
Set rs =Server.CreateObject("ADODB.Recordset")
'打开记录表
dim stime
stime = Now()
rs.open "select * from Custom where IPAddress='"&ipStr&"'",dbconnection,1,3
if rs.eof then
rs.close()
rs.Open "insert into Custom(KeyID,IPAddress,Area,loginTime)values
('"&keyid&"','"&ipStr&"','','"&stime&"')", dbconnection,1, 3
else
rs.close()
rs.Open "update Custom set loginTime ='"&stime&"' where KeyID =
'"&ipStr&"'", dbconnection,adOpenDynamic, 3
end if
%>
<%
'rs.close 无返回不需要此句
set rs=nothing
dbconnection.close
set dbconnection=nothing
%>
</body>
%后面最好不要加注释,注释加到其他行
关于ASP怎样循环读取数据库记录就分享到这里了,希望
内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/129585.html