sjgrodriguez
Posts: 26
|
Posted: 11/15/2009, 4:07 AM |
|
Hi all. I want to know how to random order an access table shown in asp by a grid.
If i go to the SQL statement and i include the RND([table_field]) , it does nothing. I need the rows to change the order each time i refhesh the page.
Im using ASP, Access and Codecharge 4.3.
Thanks in advance.
Sergio
|
|
|
Oper
Posts: 1195
|
Posted: 11/15/2009, 10:22 AM |
|
http://www.informatica.com.do/Content.asp?cid=67
be aware: if table is big, run could be very slow, use some alternate metod instead for big table.
(i use this to sort Ads random in WebSites)
# MySQL
Select Columna1,Columna2 from TABLA
order by Rand() Limit 10
# Miscrosoft SQL
Select TOP 10 Columna1,Columna2 from TABLA
order by NewID()
# PostgreSQL
Select Columna1,Columna2 from TABLA
order by Random()
# ORACLE
Select Columna1,Columna2 from
(Select Columna1,Columna2 from TABLA
order by dbms_random.value)
where rownum=10
# IBM DB2
Select Columna1,Columna2, Rand() as Ordenado from TABLA
order by Ordenado
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
|
|
sjgrodriguez
Posts: 26
|
Posted: 11/15/2009, 11:15 AM |
|
Hey Oper, thanks for your reply.
Although there´s no specific code for MS ACCESS database, i guess the right one can be:
SELECT *
FROM TABLE
ORDER BY rnd([FIELD])
The thing is that when i do it in the SQL panel, in design mode, it does perfectly. If i push the retrieve values button for three times, it orders it randomly each one. However, when i publish the project, in live view, it always orders the rows the same way....
Can be a CCS bug???
Thanks in advance.
Sergio
|
|
|
Oper
Posts: 1195
|
Posted: 11/15/2009, 5:09 PM |
|
Try rnd( seconds(time))
i dont remmenber well the name fo the seconds(...) function in Access
let me know
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
|
|
ReneS
Posts: 225
|
Posted: 11/17/2009, 1:37 AM |
|
Hi,
Do you by any chance, have a sort order field in your grid you forgot about?
Sorry if this sounds stupid....
Rene
|
|
|
sjgrodriguez
Posts: 26
|
Posted: 11/20/2009, 11:11 PM |
|
Hey ReneS, i understand your question...
Yes, i have a sort order field, with the rnd instruction.
Hey Oper, i don´t find the way of working of your suggestion... Could you please rewrite it with an example field, and number?
THANKS IN ADVANCE
Sergio
|
|
|
|