Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ASP Classic中将SQL Server数据库中的记录显示到表中_Sql_Sql Server_Asp Classic - Fatal编程技术网

在ASP Classic中将SQL Server数据库中的记录显示到表中

在ASP Classic中将SQL Server数据库中的记录显示到表中,sql,sql-server,asp-classic,Sql,Sql Server,Asp Classic,我能够在表中显示来自SQL Server db的记录。现在,我试着把它们放在3行2列的表中。这意味着如果总共有两条记录,它们应该并排出现,而不是一条接一条。我可以使用以下代码获得重复记录 <% Sub B00_DisplayRecords() Do while not registerRS.eof counter=counter+1 if counter=41 then counter=0 counter=counter+1 end if %> <tr>

我能够在表中显示来自SQL Server db的记录。现在,我试着把它们放在3行2列的表中。这意味着如果总共有两条记录,它们应该并排出现,而不是一条接一条。我可以使用以下代码获得重复记录

<%
Sub B00_DisplayRecords()
Do while not registerRS.eof
counter=counter+1
if counter=41 then
counter=0
counter=counter+1
end if
%>

<tr>    
   <th width="50" font class="tblhdr" style="width:400px;"><%=registerRS.Fields("SchoolId")%> - <%=registerRS.Fields("Organization")%></td>   
   <th width="50" font class="tblhdr" style="width:400px;"><%=registerRS.Fields("SchoolId")%> - <%=registerRS.Fields("Organization")%></td>   
</tr>    
<tr> 
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">ProductId: <%=registerRS.Fields("ProductId")%></td>
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">ProductId: <%=registerRS.Fields("ProductId")%></td>
</tr>
<tr>
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">Qty: <%=registerRS.Fields("Qty")%></td>
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">Qty: <%=registerRS.Fields("Qty")%></td>
</tr>
<tr>
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">Class: <%=registerRS.Fields("class")%></td>
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">Class: <%=registerRS.Fields("class")%></td>
</tr>        

<%
registerRS.movenext
loop
registerRS.close
set registerRS=nothing 
End sub
%>  

-    
-    
ProductId:
ProductId:
数量:
数量:
类别:
类别:
直到rs.eof
r=r+1
如果r=1,则
响应。写入“”
如果结束
'数据显示
如果r=3,则
响应。写入“”
如果结束
如果r=3,则r=1
下一个
环
如果r=2’,则写入额外的td并结束tr
如果r=1'写入2个td并结束tr
直到rs.eof
r=r+1
如果r=1,则
响应。写入“”
如果结束
'数据显示
如果r=3,则
响应。写入“”
如果结束
如果r=3,则r=1
下一个
环
如果r=2’,则写入额外的td并结束tr
如果r=1'写入2个td并结束tr

您可以使用换行符。看起来没有任何记录会自动换行。正如我在下面所说的那样,创建列,但将每条记录放在一个TDU中,您可以使用换行符。看起来没有任何记录会自动换行。按照我下面所说的做,制作列,但将每条记录放在一个单独的td中
Do until rs.eof

    r = r + 1

    If r = 1 then
        Response.write "<tr>"
    End if

    ' data display

    If r = 3 then
        Response.write "</tr>"
    End if

    If r = 3 then r = 1

Rs.movenext
Loop

If r = 2 ' write extra td and end tr
If r = 1 ' write 2 td and end tr