Wrox Programmer Forums
|
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 8th, 2003, 04:50 AM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default NEWID()

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.......




L Ion
__________________
L Ion
 
Old November 10th, 2003, 06:21 PM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I sorted out this way:

<%
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
%>

Thanks for help.

L Ion





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to seed or increment NEWID() value suji SQL Server 2005 4 February 19th, 2008 02:45 PM
NEWID() in Access Database Lucian Ion Dreamweaver (all versions) 1 November 10th, 2003 06:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.