'定义变量 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 |