 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 15th, 2006, 01:11 AM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Recordset Count starting from 1 till end
Hello evryone.
I want to display a number counting from 1 till the amount of records in my db. How can I do this with recordset count???
need help tnx....
peace
__________________
-------------------------
peace, luv and respect
|
|

October 15th, 2006, 10:14 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
The recordset.count will only count the number of rows of data returned to you via your query (depending on your query this may or may not be the actual number of rows of data in your database).
This article might help you:
http://www.asp101.com/samples/viewas...%5Fcount%2Easp
That is a zero-based count so you would have to set the value of recordcount to a variable and add 1 to it, or you could simply execute this query:
SELECT count(field) from table
Where field is any column in your table and it will return you the number of rows that exist in the table.
hth
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

October 15th, 2006, 12:09 PM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yeah tnx for replying, I already saw that article but I couldn't figure out the codes. First I used the code as it is and it doen't display a thing -> full blank page. Then I changed the DB_CONNSTRING and no success.
I use iis on my local machine.
How can I still do it with this code??
|
|

October 15th, 2006, 12:16 PM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
One more thing what I wanted was this:
e.g.
Members
1 John
2 Mary
3 Edward
4 Raymond
5 Sally
And the numbers 1 till 5 is the asp code, they are not derived from the database but the names are well derived from the db.
When I saw the db of the article and the output of the sample it doent looked like what I wanted to do.
My english aint 100% if you didnt understand me let me know.......
One more time tnx..
|
|

October 15th, 2006, 03:25 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Since you want that just do this:
Dim iIndex
iIndex = 1
While Not rs.eof
response.write iIndex & " " & rs("field")
iIndex = iIndex + 1
Wend
hth.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

October 15th, 2006, 04:29 PM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
dparsons tnx
that was exactly the the code I was looking for, do you know how you can let it keep counting when you use paging.
Here's my code:
Dim iIndex
iIndex = 1
For i=1 To 25
If Not rsMiembro.eof And Not rsMiembro.bof Then
'Write the HTML to display the current record in the recordset
Response.Write ("<tr><td>")
Response.Write iIndex
Response.Write ("</td>")
Response.Write ("<td width=10> </td>")
Response.Write ("<td>")
Response.Write (rsMiembro("nomber"))
Response.Write ("</td>")
Response.Write ("<td width=10> </td>")
Response.Write ("<td>")
Response.Write (rsMiembro("fam"))
Response.Write ("</td>")
Response.Write ("</tr>")
iIndex = iIndex + 1
'Move to the next record in the recordset
rsMiembro.MoveNext
End If
Next
Response.Write ("</table>")
Response.Write ("</form>")
Response.Write "<p><table><tr>"
For i=1 To rsMiembro.PageCount
Response.Write "<td><a href='memb_del.asp?pg=" & i & "'><div class='pglink'>" & i & "</div></a>"
Next
peace, luv and respect
|
|

October 15th, 2006, 04:41 PM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I've found this code but how can I put a loop into it:
Dim iIndex
iIndex = 1
if rsMiembro.AbsolutePage=2 then iIndex=26
if rsMiembro.AbsolutePage=3 then iIndex=51
if rsMiembro.AbsolutePage=4 then iIndex=76
For i=1 To 25
If Not rsMiembro.eof And Not rsMiembro.bof Then
etc....
peace, luv and respect
|
|

October 15th, 2006, 05:40 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
What do you mean?
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

October 15th, 2006, 10:20 PM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
With the code that you gave me:
Dim iIndex
iIndex = 1
While Not rs.eof
response.write iIndex & " " & rs("field")
iIndex = iIndex + 1
Wend
I get this on my page:
http://c.1asphost.com/nouky/miembro2.asp
With this code:
Dim iIndex
iIndex = 1
if rsMiembro.AbsolutePage=2 then iIndex=26
if rsMiembro.AbsolutePage=3 then iIndex=51
if rsMiembro.AbsolutePage=4 then iIndex=76
For i=1 To 25
If Not rsMiembro.eof And Not rsMiembro.bof Then
etc....
I get this output:
http://c.1asphost.com/nouky/miembro.asp
My question is how can I prevent writing this code or convert it into a LOOP:
if rsMiembro.AbsolutePage=2 then iIndex=26
if rsMiembro.AbsolutePage=3 then iIndex=51
if rsMiembro.AbsolutePage=4 then iIndex=76
Because each time I have to write a new line when I add more people to the database.My question is how can I convert the code in a Loop??
-------------------------
peace, luv and respect
|
|

October 16th, 2006, 08:28 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Your webserver is refusing my connection and I can't view what you your examples (I will look at them when i get home from work tonight)
I assume that you have your page size set to 25 anyway you could do this caluclation to figure out what your iIndex should be:
Dim iPage, iValue
iPage = CInt(rsMiembro.AbsolutePage)
iValue = (iPage * 25) - 24
iIndex = iValue
So if iPage is 1 iValue will be one, if iPage is 2 i value will be 26 so on and so forth.
hth.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|
 |