asp用<%=rs("Title")%>显示access数据库中的内容

asp用<%=rs("Title")%>显示access数据库中的内容,第1张

<%

set rs = serverCreateObject("adodbrecordset")

rsopen "select from 表名 order by id desc",conn,1,1

if rseof and rsbof then

responseWrite "还没有内容"

else

do while not rseof

responseWrite rs("title")&"<br>"

rsmovenext

loop

rsclose

set rs = nothing

end if %>

以上有多少显多少

rsopen "select top 2 from 表名 order by id desc",conn,1,1

则只显示2条,更改top 2 为几,就显示几条

个人建议采集到的数据存储为二维数组,其中商品id是唯一的,所以将id作为键值,然后每个键值对应的是一个一次包含title,price等数据的二维数组,这样采集完成后,可以将这个二维数组遍历循环插入数据库,这样也不容易出现错误

比如其中一个商品id为1,标题为“牙刷”,价格为$2,就这样写入数组$arr[1]=array("牙刷","$2")

<%@language="vbscript"%>

<%option explicit %>

<%

dim conn,strcon,rs

dim strSQLSeverName

dim strSQLDBUserName

dim strSQLDBPassword

dim strSQLDBName

strSQLSeverName="1009172" 服务器IP地址

strSQLDBUserName="sa"

strSQLDBpassword=" " 密码

strSQLDBName="wz" 数据库名

set conn=ServerCreateObject("adodbconnection")

strcon ="provider=SQLOLEDB1;Persist Security info=false;server=" & strSQLSeverName & ";user id=" & strSQLDBUserName & ";Password=" & strSQLDBpassword & ";database=" & strSQLDBName &";"

connopen strcon

dim rsstr ="select from title"

set rs = servercreatobject("adodbrecordset")

rsopen rsstr,conn,2,2

if not rseof then

%>

<html>

<body>

<table>

<tr>

<td>TITLE</td>

<td>CONTENT</td>

</tr>

<% do while not rseof%>

<tr>

<td><%=rs("title")%></td>

<td><%=rs("content")%></td>

</tr>

<%rsmovenext

loop%>

</table>

</body>

<%end if%>

<=$row[title]>

< >这个是php的短标签识别符,不过建议用<php >

=表示输出

$row为数组,$row[title]里的title为$row数组里的一个下标

$row多数用在数据库读取,所以这里可能是显示数据库中的title字段

以上就是关于asp用<%=rs("Title")%>显示access数据库中的内容全部的内容,包括:asp用<%=rs("Title")%>显示access数据库中的内容、php用正则采集到多个数据如何写入数据库 现在我用php正则采集到了,商品名称title:1,2,3,...n;商品id...、sql数据库名为wz 表单名为title title里面有title,content字段 想在asp页面实时输出title表内数据 要详码等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9786312.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-02
下一篇2023-05-02

发表评论

登录后才能评论

评论列表(0条)

    保存