Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) 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 6th, 2003, 06:48 PM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default NEWID() in Access Database

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



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
Database Connection to Access Database reachsevar ASP.NET 2.0 Basics 1 November 28th, 2007 08:56 AM
Remote access to an Access Project Database bright_mulenga Access 0 February 9th, 2006 10:51 AM
Access issues with ASP and a MS Access Database rj_conceptsnrec.com Classic ASP Databases 2 May 19th, 2005 12:44 PM
NEWID() Lucian Ion Access ASP 1 November 10th, 2003 06:21 PM





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