CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 How to order by random values a grid

Print topic Send  topic

Author Message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.