想象作文未来的书包:asp查询access的问题,高手请指点!!!
来源:百度文库 编辑:神马品牌网 时间:2024/10/06 09:39:20
在线等!!
QQ:583883023
<%
set rs=conn.execute("select top 8 id,产品名称,授权标志,所属类别 from 产品表名 where 产品名称 like '%笔%' and 授权标志=1 order by id desc")
%>
<table width="100%">
<%
do while not rs.eof
%>
<tr><td <%if icolor=0 then response.write"bgColor=#f0f0f0" else response.write"bgColor=#ffffff" end if%>>· <a title='<%=rs("产品名称")%>' href='详细页面.asp?ID=<%=rs("ID")%>' target='_blank'><%=left(rs("产品名称"),8)%></a></td></tr>
<%
icolor=icolor+1
if icolor>1 then icolor=0
rowcount=rowcount-1
rsnews.movenext
loop
%></table>
解释:
<%if icolor=0 then response.write"bgColor=#f0f0f0" else response.write"bgColor=#ffffff" end if%>
第1行bgColor=#f0f0f0
第2行bgColor=#ffffff
后面的就是控制语句
icolor=icolor+1
if icolor>1 then icolor=0
rowcount=rowcount-1
db=mappath("数据库名")
connstr="Provider=Microsoft.OLEDB.Jet.4.0;Data Source="&db
set conn=server.creatobject("adodb.connection")
conn.open connstr
sql = "select * from 表名"
set rs = server.creatobject("adodb.recordset")
rs.open conn,sql,1,1
for i=0 to rs.count
response.write rs(i).name '显示字段名
next
rs.close
set rs=nothing
sql="select * from 表名
set rs=server.creatobject("adodb.recordset")
rs.open conn,sql,1,1
do while no rs.eof
response.write rs("相显示内容的字段名")&"<br>"
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing