Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Retrieving more records from 1 field
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Retrieving more records from 1 field

 Post Reply Post Reply Page  12>
Author
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Topic: Retrieving more records from 1 field
    Posted: 14 October 2003 at 6:54am

I have a field (TestID) in which I store the ID of the quizes a user is allowed to take. It could be 1 records, could be several, coma delimited (like 1, 2, 39, 103).

How could I pull them from db one by one? as I need to pass them to a query string like in examiner.asp?quizID=1?

Cristian Banu
Soft 4 web
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 14 October 2003 at 8:19am
I would query the whole field and split the values into an array. will be easier to work with that way.
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 14 October 2003 at 8:26am

Kind of knew that, but I do not know how to write it! I have tryed

  <%
   dim i, j
i=1
Set rs= MyConn.Execute("Select TestID from Login Where UserName = '" & Session("UserName") &"'")
While i < len(rs("TestID"))
  j=instr(i, ",", rs("TestID"))
  response.write("<p><a href = examiner.asp?quizID=" & mid(rs("TestID"), i, j-i-1) & ">" & "Test " & i & "</a></p>")
  i=j+1
Wend
rs.close
set rs = nothing%></p>
     

But it triggers the error : Invalid procedure call or argument: 'mid'

Cristian Banu
Soft 4 web
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 14 October 2003 at 12:24pm

dim i,counter, testids
Set rs= MyConn.Execute("Select TestID from Login Where UserName = '" & Session("UserName") &"'")
testids = Split(rs("TestID"),",")
i = ubound(testids)
For counter = 0 to i
 Response.Write "TestID= " & testid(counter)
NEXT

This should work, have not tested it, just give it a shot...

Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 14 October 2003 at 3:33pm
Thanks Michael, that worked.
Cristian Banu
Soft 4 web
Back to Top
Flamewave View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 June 2002
Location: United States
Status: Offline
Points: 376
Post Options Post Options   Thanks (0) Thanks(0)   Quote Flamewave Quote  Post ReplyReply Direct Link To This Post Posted: 15 October 2003 at 11:42am
Seems like an awful lot of overhead, if you are intrested in improving the performance of this, I would create another table that has a column for the user id and a colum for the test id, and then enter in a single record for each test id that the user has access to, you can then use a select statement to find out if the user has access to that test, and skip all of the array splitting and comparison stuff asp side.
- Flamewave

They say the grass is greener on the other side, but if you really think about it, the grass is greener on both sides.
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 15 October 2003 at 12:38pm
Creating another table would fill the db with thousands of useless records. I think the performance would be much more affected while looping through thousands records than spliting one record into several others.
Cristian Banu
Soft 4 web
Back to Top
Flamewave View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 June 2002
Location: United States
Status: Offline
Points: 376
Post Options Post Options   Thanks (0) Thanks(0)   Quote Flamewave Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 1:28am
Depends on what database you are using. If you are using SQL, then you can use stored procs and views to do the select statements, and its about 10x faster (well, maybe thats an exaguration) then looping through it ASP side, excpecially (damn I need to learn how to spell one of these days) if you have thousdands of recordsets. If you are using Access, then there probally wouldn't be much if any of a difference in speed between the two, although you can still use the "querries" section of Access to create an equivialnt of a view in SQL server, that can greatly speed up the performance. If its something other then Access or SQL, I don't know enugh about them to voice my opinion on performance with them.
- Flamewave

They say the grass is greener on the other side, but if you really think about it, the grass is greener on both sides.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.