Question : How to display the number of returned rows

I would like the first column display the number of returned rows. How could I add a column which displays the number of each returned row?
Thank you
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
<html>
<body>

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT Companyname, Contactname FROM Customers"
rs.Open sql, conn
%>

<table border="1" width="100%">
<tr>
<%for each x in rs.Fields
    response.write("<th>" & x.name & "</th>")
next%>
</tr>
<%do until rs.EOF%>
    <tr>
    <%for each x in rs.Fields%>
       <td><%Response.Write(x.value)%></td>
    <%next
    rs.MoveNext%>
    </tr>
<%loop
rs.close
conn.close
%>
</table>

</body>
</html>

Answer : How to display the number of returned rows

<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("guest.mdb")

Dim rs
set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT * FROM messages"
Set rs = conn.Execute(sql)

%>
<html>
<head>
<title>All Data</title>

</head>
<body>
<table bgcolor="#ffffff" border="1" align="center" bordercolor="000080" cellpadding="2" cellspacing="0" style="border-collapse:collapse">
<tr bgcolor="#eeeeee">
<th>Number</th>
<th>Name</th>
<th>Emp. #</th>
<th>Email Address</th>

</tr>
<%
if not (rs.EOF or rs.BOF) then rs.movefirst
sNum = 0
do until rs.EOF
%>
<tr>
<td>
<%
sNum = sNum +1
Response.Write(sNum)
%>

</td>
<td><%= rs("Name")%></td>
<td><%= rs("EmpNum")%></td>
<td><%= rs("Email")%></td>
</tr>

<%
rs.MoveNext
loop
rs.Close
conn.Close
%>
</table>

</body>
</html>
Random Solutions  
 
programming4us programming4us