Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Access Database & NEWID()

  • 06-11-2003 10:49pm
    #1
    Closed Accounts Posts: 40


    I am working on this project and I want to display a random recordset, but it does not seem towork with Access at all.

    I have it workin in SQL 2000 database but access is more complicated.

    Can anyone help?

    <%
    Dim rsSpecials
    Dim rsSpecials_numRows

    Set rsSpecials = Server.CreateObject("ADODB.Recordset")
    rsSpecials.ActiveConnection = MM_conn_STRING
    rsSpecials.Source = "SELECT P_Name, P_OnSpecial, P_OnSpecialPrice, P_SmallPicture, P_ID, NEWID() AS P_ID1 FROM Products WHERE P_OnSpecial=yes ORDER BY P_ID1"
    rsSpecials.CursorType = 0
    rsSpecials.CursorLocation = 2
    rsSpecials.LockType = 1
    rsSpecials.Open()

    rsSpecials_numRows = 0
    %>

    The NEWID() part is the problem.

    I tried RAND() but.......


Comments

  • Closed Accounts Posts: 40 lucian


    For everybody who ever gets into the same position I was in, I sorted out like this:

    <%
    Const adCmdText = &H0001

    Dim rsNewProducts
    Dim rsNewProducts_numRows

    Set rsNewProducts = Server.CreateObject("ADODB.Recordset")
    rsNewProducts.ActiveConnection = MM_conn_STRING
    rsNewProducts.Source = "SELECT * FROM NewProducts ORDER BY P_DATEADDED"
    rsNewProducts.CursorType = 0
    rsNewProducts.CursorLocation = 3
    rsNewProducts.LockType = 1
    rsNewProducts.Open()

    rsNewProducts_numRows = 0

    Dim intRnd
    Randomize Timer
    intRnd = (Int(RND * rsNewProducts.RecordCount))

    ' Now moving the cursor to random record number
    rsNewProducts.Move intRnd
    %>


Advertisement