这篇文章给大家介绍ASP怎样循环读取数据库记录,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
<%@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>
%后面最好不要加注释,注释加到其他行
关于ASP怎样循环读取数据库记录就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
名称栏目:ASP怎样循环读取数据库记录-创新互联
文章出自:https://www.cdcxhl.com/article30/deiopo.html
成都网站建设公司_创新互联,为您提供移动网站建设、网页设计公司、手机网站建设、ChatGPT、全网营销推广、App设计
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联