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

 Random record

Print topic Send  topic

Author Message
flipandboef


Posts: 107
Posted: 04/16/2007, 8:32 AM

I have tried to find it on the forum but cannot find a solution...

I have a MS-Access db with a table Members... One of the fields is calles Mailing... I now want to draw randomly one person who is a member of this Mailing (=true) and have this displayed on my page... I don't care if it changes each time with a refresh or not so no worries there...
How can I accomplish this?

The table Members looks as followed:
MemberID (long int/prim key)
FName (text)
LName (text)
Email (text)
Mailing (Boolean)

I am not a coding guru, use CCS 3.0 pretty basic, so please have patience with me on the coding part O:)

Most likely I am looking for a piece of code that randomly picks from the field MemberID and I assume I have to place that code in the BeforeShow event...

Anyone who can help me out?
View profile  Send private message
wkempees


Posts: 1679
Posted: 04/16/2007, 3:18 PM

http://forums.codecharge.com/posts.php?post_id=86257&s_keyword=rand%28%29

might be helpful, look at my post there.

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
flipandboef


Posts: 107
Posted: 06/27/2007, 1:37 PM

Hi Walter, thanks for that reply... Couldn't try it out for a while, but now I'm back on it again...

I've tried your code in the SQL statement, but when doing that, it gives me an error when trying to view the page.. Again (I know) I am a dummy in this field...
The code I used:
select * from Members order by rand() limit 1

This gave me the error:
ADODB.Recordset error '800a0e78'

Operation is not allowed when the object is closed.

/Classes.asp, line 3320


Looking at this line it states:
If Not IsEmpty(mCountSQL) And Len(CountSQL) = 0 And NOT DataSource.Recordset.EOF Then

Am I missing something here??


Also tried in the SQL (Data Source - setting Table to SQL on the top):
SELECT *
FROM MEMBERS
WHERE ((([Members]![Mailing])=True))
ORDER BY Rnd(IsNull(MEMBERS.MemberID)*0+1);

This gives me no erros!! But gives me 1 name only.. Refresh does not help, even closing the page, deleting cache etc.. same name pops up (so far for random...)
Enable caching is set to No...

Any ideas on this?

note: I used this in my Access DB Select query and works great in there. Just to much work downloading the DB, running that query and u/l it again...
View profile  Send private message
flipandboef


Posts: 107
Posted: 06/27/2007, 2:33 PM

Never ind i found the solution!! :

SELECT *
FROM MEMBERS
WHERE Mailing = {Expr0}
ORDER BY Rnd(-(Second(Now())*MemberID))

Expr0 = TRUE

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

Web Database

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.