当前位置: 移动技术网 > IT编程>开发语言>Asp > 将ASP记录集输出成n列的表格形式显示的方法

将ASP记录集输出成n列的表格形式显示的方法

2017年12月12日  | 移动技术网IT编程  | 我要评论
'定义变量 dim cn,rs,sql sql = "select customerid from orders" '记录总数 dim totalnumbe set cn
'定义变量
dim cn,rs,sql
sql = "select customerid from orders"
'记录总数
dim totalnumbe
set cn = server.createobject("adodb.connection")
cn.open "provider=sqloledb.1;user id=sa;initial catalog=northwind;data source=.;password=;"
set rs = server.createobject("adodb.recordset")
rs.open sql, cn, 3, 1
totalnumber = rs.recordcount
if totalnumber = 0 then
response.write "没有记录输出。"
else
dim jj,nleft,ccol
jj = 0
ncol = 415
nleft = ncol- (totalnumber mod ncol)
if nleft = ncol then nleft = 0
response.write "<table border><tr>" & vbcrlf
while not rs.eof
response.write "<td>" & rs("customerid") & "</td>" & vbcrlf
'if (jj mod ncol) = (ncol - 1) and jj <> totalnumber - 1 then response.write "</tr><tr>" & vbcrlf
'if (jj mod ncol) = (ncol - 1) and jj = totalnumber-1 then response.write "</tr>" & vbcrlf
if (jj mod ncol) = (ncol - 1) then
if jj <> totalnumber - 1 then
response.write "</tr><tr>" & vbcrlf
else
response.write "</tr>" & vbcrlf
end if
end if
jj = jj + 1
rs.movenext
wend
if nleft <> 0 and nleft <> ncol then
if ncol < totalnumber then
for i = 1 to nleft
response.write "<td> </td>" & vbcrlf
next
end if
response.write "</tr>" & vbcrlf
end if
response.write "</table>"
end if
rs.close
set rs = nothing
cn.close
set cn = nothing
response.end

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网