欢迎光临
我们一直在努力

将ASP纪录集输出成n列表格的方法-ASP教程,ASP应用

建站超值云服务器,限时71元/月

前些日子有网友问:将asp纪录集输出成n列的的表格形式显示的方法,现在写了一个,方便大家使用。

  定义变量

  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>&nbsp;</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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 将ASP纪录集输出成n列表格的方法-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章