Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
AbsolutePosition Problem
Old 05-27-2006, 03:21 PM AbsolutePosition Problem
Junior Talker

Posts: 2
Trades: 0
Hi,
I am having a problem with the AbsolutePosition method.
Here is the code:
Code:
function PositionOfMyAd(p_user)  
set rsTable = Server.CreateObject("ADODB.Recordset")
rsTable.Open "SELECT p_name, p_user FROM tblUsers ORDER BY p_rating DESC ", MM_conn_STRING, 1,3
while NOT rsTable.EOF

    Response.Write("user=" & rsTable("p_name") & "position=" &    rsTable.AbsolutePosition & "<br>")
rsTable.Movenext
wend
rsTable.Close 
set rsTable = Nothing
end function
I am getting "-1" values.
I have tried several cursor types but I am getting the same result.
Any ideas?

And another question
Maybe someone can suggest me with a way to find a position of a recordset in DB.
I have a list of users that are "rated" by 'p_rating" value and I would like to return a position of some spesific user in the DB sorted by "p_rating"
netbka is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-27-2006, 04:18 PM Re: AbsolutePosition Problem
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
This is why I hate the default ASP samples provided...they're so useless.

Anyway, the first thing you should be doing is using a sub instead of a function. Functions are only meant to be used when you want to return a value back to your script. Subs are used to process blocks of code (which is what your sample is.)

Second, instead of using a while loop, use a for loop to iterate through your recordset.
Code:
for i = 1 to RS.RecordCount
 Response.Write("user=" & rsTable("p_name") & "position=" & i & "<br>")

Next
Since the i is a for loop counter, it will increase by one each time.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 05-27-2006, 06:53 PM Re: AbsolutePosition Problem
Junior Talker

Posts: 2
Trades: 0
Hey!
Yeah, it's nice way do complete the task but i don't want to scroll through
the entire DB. ( not in the original task )

I need to find some position of a recordset in the DB. In your way I will have to pass through all the query to find the one I need.
I thought about using the .Find operation that will return me the position of the record.
Like:
Code:
rsTable.Open "SELECT p_name, p_user FROM tblUsers ORDER BY p_rating DESC ", MM_conn_STRING, 1,3
'rsTable.Find "p_user = '" & p_user & "'", 1, 1, 1 
Response.Write("user=" & rsTable("p_name") & "position=" & rsTable.AbsolutePosition & "<br>")

How can that be done?
netbka is offline
Reply With Quote
View Public Profile
 
Old 05-27-2006, 08:28 PM Re: AbsolutePosition Problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
AbsolutePosition does not tell you the position of a record in the table, it tells you the position in the recordset.

the CursorLocation must be adUseClient (3).

does the database type you are using support the property ?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-28-2006, 01:50 AM Re: AbsolutePosition Problem
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
You're going to have to iterate through it somehow to do this. Whether you do it using the recordset or you output the recordset to an array and do it that way, it still has to be compared in this manner.

There really isn't a better way to do it.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to AbsolutePosition Problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15896 seconds with 12 queries