Friday, March 5, 2010

Selecting Random Row from MS Access table

In my previous post, I have explained about selecting random row using php and mysql.

Today I get a chance to see the code which was written in ASP for selecting random row from ms access table.

It seems there is no straight way for doing this. We had to write code something similar to below one.

set rs=server.CreateObject("ADODB.recordset")

rs.Open "select quotes from quotes",connObj,3,3


intRangeSize = rs.recordcount - 1 + 1

sngRandomValue = intRangeSize * Rnd()

intRandomInteger = Int(sngRandomValue)

for i=1 to intRandomInteger



response.write rs("quote")

So, it is very obvious that php/mysql is very easy and effective while comparing with ASP/MS-Access. But I couldn't understand why people are still using ASP/MS-access.

If you want to convert your asp webpage into php webpage you can refer my previous post about asp to php conversion.

Anyway, I think random row from sql server can be easily fetched just by adding "order by newid()" in the query.

More Articles...

You can bookmark this blog for further reading, or you can subscribe to our blog feed.

No comments:

Search This Blog