ManicCW
Well-known member
Hi,
I'm trying to select 3 random records from access database usign asp.net oledbcommand. I select records from query.
This is the command:
[/SIZE]
This is the RandomImages query in access database:
The problem with this is that it selects the same 3 records every time. It works fine in database but not on page!?
I found somewhere that i can put function in access database module that randomizes but that only works in database, on page it throws an error that function does not exists.
Here is that function
Is there a sloution. I dont want to load all records and then filter and randomize it in code!!!
I'm trying to select 3 random records from access database usign asp.net oledbcommand. I select records from query.
This is the command:
VB.NET:
[SIZE=2]"SELECT TOP 3 ID, Name, Title, CreationTime " & _
"FROM RandomImages"
This is the RandomImages query in access database:
VB.NET:
SELECT Images.*
FROM Images
ORDER BY Rnd(IsNull(ID)*0+1);
The problem with this is that it selects the same 3 records every time. It works fine in database but not on page!?
I found somewhere that i can put function in access database module that randomizes but that only works in database, on page it throws an error that function does not exists.
Here is that function
VB.NET:
Function Randomizer () As Integer
Static AlreadyDone As Integer
If AlreadyDone = False Then Randomize : AlreadyDone = True
Randomizer = 0
End Function
Is there a sloution. I dont want to load all records and then filter and randomize it in code!!!