<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%Session.CodePage = 936%>
<!DOCTYPE html PUBLIC "-//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 name="viewport" content="width=device-width, initial-scale=1.0,
minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" >
<title>Scale3DC2018Read</title>
</head>
<body>
<%
Set conn= Server.CreateObject("ADODB.Connection")
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=
"&Server.MapPath("\database\Scale3DCIP.mdb")
conn.Open connstr
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from custom order by id desc"
rs.Open sql,conn,1,1
do while not rs.eof
%>
<table border=1>
<tr>
<td><%=rs("keyid")%></td>
<td><%=rs("IPAddress")%></td>
<td><%=rs("Area")%></td>
<td><%=rs("LoginTime")%></td>
</tr>
<%
rs.movenext
loop
rs.close()
set rs = nothing
conn.close()
set conn = nothing
%>
</table>
</body>
写入数据库
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%Session.CodePage=936%>
<!--#include file="web\\global.inc"-->
<!DOCTYPE html PUBLIC "-//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>
%后面最好不要加注释,注释加到其他行
转载于:https://blog.51cto.com/9233403/2162518