Random Record Problem ASP.NET + MX + ACCESS

  • Thread starter Thread starter tdi1686
  • Start date Start date
T

tdi1686

I am using the following SQL (Access) code to pick some records out of a
table of 200 or so records. The ASP.NET code utilizes Dreamweaver MX's
MM:Dataset.

SELECT TOP 1 *
FROM specUsedCars
ORDER BY Rnd([carID]);

SELECT *
FROM specUsedCars
ORDER BY RND([carID]);

This does pick a random record, however it always picks the same one. At
first I thought that it was just caching it but it appears not.

I have tried creating a Query in the Access DB using the above code and then
in the ASP.NET code doing a SELECT * from Queryname but that produces the
same.

I have read about creating Modules in access using the VB
randomize/randomizer function but I dont know how to do this.
 
Okay I take it that means writing a module.

Never done that before in access. Strewth I wish i could use SQL Server, the
ease of ORDER by newID()

Could you give me some pointers, or point me to a tutorial. I have RTFM but
Access is not Books online thats for sure.

tdi1686


chriske911 said:
like in VB you first have to Randomize since the Rnd function does the same
calculation in the same timeslot thus producing the same outcome,
to have a different outcome each time you use the Rnd function you will have
to Randomize first

bon change
tdi1686 said:
I am using the following SQL (Access) code to pick some records out of a
table of 200 or so records. The ASP.NET code utilizes Dreamweaver MX's
MM:Dataset.

SELECT TOP 1 *
FROM specUsedCars
ORDER BY Rnd([carID]);

SELECT *
FROM specUsedCars
ORDER BY RND([carID]);

This does pick a random record, however it always picks the same one. At
first I thought that it was just caching it but it appears not.

I have tried creating a Query in the Access DB using the above code and then
in the ASP.NET code doing a SELECT * from Queryname but that produces the
same.

I have read about creating Modules in access using the VB
randomize/randomizer function but I dont know how to do this.
 
I tried your rnd query on a few tables and it always gave me another record
or a different sorting
I don't know why it doesn't work for you though

code a simple module like this :

Function RandomViewData(RandQuery As String)
On Error GoTo errhandler

Randomize
DoCmd.OpenQuery RandQuery, acViewNormal, acReadOnly

exit_errhandler:
Exit Function

errhandler:
MsgBox "please provide a correct recordset", vbOKCancel, "error executing
RandomViewData"

End Function

you can call it from where you want by calling RandomViewData(
name_of_your_query)

bon chance

tdi1686 said:
Okay I take it that means writing a module.

Never done that before in access. Strewth I wish i could use SQL Server, the
ease of ORDER by newID()

Could you give me some pointers, or point me to a tutorial. I have RTFM but
Access is not Books online thats for sure.

tdi1686


chriske911 said:
like in VB you first have to Randomize since the Rnd function does the same
calculation in the same timeslot thus producing the same outcome,
to have a different outcome each time you use the Rnd function you will have
to Randomize first

bon change
tdi1686 said:
I am using the following SQL (Access) code to pick some records out of a
table of 200 or so records. The ASP.NET code utilizes Dreamweaver MX's
MM:Dataset.

SELECT TOP 1 *
FROM specUsedCars
ORDER BY Rnd([carID]);

SELECT *
FROM specUsedCars
ORDER BY RND([carID]);

This does pick a random record, however it always picks the same one. At
first I thought that it was just caching it but it appears not.

I have tried creating a Query in the Access DB using the above code
and
then
in the ASP.NET code doing a SELECT * from Queryname but that produces the
same.

I have read about creating Modules in access using the VB
randomize/randomizer function but I dont know how to do this.
 
Back
Top