locked
Random order display in datalist and gridview from access database RRS feed

  • Question

  • User599735860 posted

    Hi

    I have to display data (names) in a random order on the website.

    The data is stored in a MS Access database.

    The names must be displayed in a GridView and DataList in different places.

    I have created a query in MS Access "zorder: Rnd([MarinaAccommodation]![ID])" which works fine in MS Access giving me a different order each time.

    The problem is that when I try run it on the website the order remains the same, it does not change each time the page is loaded.

    Does anyone have a suggestion to help.

    Thanks

    Michael


    Thursday, July 8, 2010 6:32 AM

Answers

  • User-1199946673 posted

    try to use :

    ORDER BY NEWID()
     

     

    He's using Access, not SQL Server. NEWID() isn't supported in Access, so this won't work.

    Read this reply I made some time ago....

    http://forums.asp.net/t/1158634.aspx#1910539

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 8, 2010 3:38 PM
  • User599735860 posted

    Thank you the advice on http://forums.asp.net/t/1158634.aspx#1910539 it worked.

    For anyone else wishing to do this: Make a query in MS Access with the data you want to display in a random order and then place make an additional field with this, Order: Rnd(-10000000*TimeValue(Now())*[id]) in your asp.net dataview order by "order"

    It's great when things work.

    Thank you for the advice.

    Michael

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 11, 2010 9:51 AM

All replies

  • User191633014 posted

    try to use :

    ORDER BY NEWID()
     

    Thursday, July 8, 2010 8:59 AM
  • User599735860 posted

    Thanks for the advise, I am not good with this, can you please give a bit more details, everything I tried did not work.

    Thursday, July 8, 2010 9:21 AM
  • User-1199946673 posted

    try to use :

    ORDER BY NEWID()
     

     

    He's using Access, not SQL Server. NEWID() isn't supported in Access, so this won't work.

    Read this reply I made some time ago....

    http://forums.asp.net/t/1158634.aspx#1910539

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 8, 2010 3:38 PM
  • User599735860 posted

    Thank you the advice on http://forums.asp.net/t/1158634.aspx#1910539 it worked.

    For anyone else wishing to do this: Make a query in MS Access with the data you want to display in a random order and then place make an additional field with this, Order: Rnd(-10000000*TimeValue(Now())*[id]) in your asp.net dataview order by "order"

    It's great when things work.

    Thank you for the advice.

    Michael

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 11, 2010 9:51 AM