R
rn5a
I want an ASP app to retrieve records from a MS-Access database table
but display them in a HTML table but I want the HTML table table to
display only 7 records in a row (<tr>...</tr>) in 7 different cells
(<td>...</td>). In other words, if there are 14 records in the DB
table, the HTML table should display the 14 records in 2 rows - the
1st row displaying the 1st 7 records from the DB table & the 2nd row
displaying the remaining 7 records existing in the DB table. This is
how I did it:
------------------------------------------------
<%
On Error Resume Next
Dim objConn
objConn=Server.CreateObject("ADODB.CONNECTION")
'open the connection using ConnectionString
Dim strSQL
strSQL="SELECT * FROM MyTable ORDER BY Col1"
Dim objRS
Set objRS=Server.CreateObject("ADODB.RECORDSET")
objRS.Open strSQL,objConn
Dim iCount
%>
<table border=1>
<%
Do Until(objRS.EOF)
%>
<tr>
<%
For iCount=iCount To iCount+6
%>
<td><%= objRS("Col1") %></td>
<%
objRS.MoveNext
Next
%>
</tr>
<%
Loop
%>
</table>
------------------------------------------------
The above code does display the records how I want to display but to
be honest, I couldn't exactly understand the logic of the above code.
Can someone please explain me the logic behind the above code?
Also note the On Error Resume Next line. Though the above code
displays the records exactly how I want them to be displayed in the
HTML table, if I comment the On Error Resume Next line, then ASP
generates the
Exception occured.
error without pointing to any line. I know what's causing the error
but can't find a way out to overcome the error. Can someone please
help me resolve this error as well?
Thanks.
but display them in a HTML table but I want the HTML table table to
display only 7 records in a row (<tr>...</tr>) in 7 different cells
(<td>...</td>). In other words, if there are 14 records in the DB
table, the HTML table should display the 14 records in 2 rows - the
1st row displaying the 1st 7 records from the DB table & the 2nd row
displaying the remaining 7 records existing in the DB table. This is
how I did it:
------------------------------------------------
<%
On Error Resume Next
Dim objConn
objConn=Server.CreateObject("ADODB.CONNECTION")
'open the connection using ConnectionString
Dim strSQL
strSQL="SELECT * FROM MyTable ORDER BY Col1"
Dim objRS
Set objRS=Server.CreateObject("ADODB.RECORDSET")
objRS.Open strSQL,objConn
Dim iCount
%>
<table border=1>
<%
Do Until(objRS.EOF)
%>
<tr>
<%
For iCount=iCount To iCount+6
%>
<td><%= objRS("Col1") %></td>
<%
objRS.MoveNext
Next
%>
</tr>
<%
Loop
%>
</table>
------------------------------------------------
The above code does display the records how I want to display but to
be honest, I couldn't exactly understand the logic of the above code.
Can someone please explain me the logic behind the above code?
Also note the On Error Resume Next line. Though the above code
displays the records exactly how I want them to be displayed in the
HTML table, if I comment the On Error Resume Next line, then ASP
generates the
Exception occured.
error without pointing to any line. I know what's causing the error
but can't find a way out to overcome the error. Can someone please
help me resolve this error as well?
Thanks.