Friday, July 14, 2006

SELECT random records from a database

asp script:
randomize
sql="select max (ID) as maxid from table"rs.open sql,cn
max=rs("maxid")
rs.close

for i=0 to 100
rndNum=int(rnd()*max)+1
idstr=idstr&rndNum&","
next
idstr=idstr+"0"

sql="select top 25 ID, * from table where ID in ("+idstr+")"
rs.open sql,cn



<% randomize sql="select max (ID) as maxid from table" rs.open sql,cn max=rs("maxid") rs.close for i=0 to 100 rndNum=int(rnd()*max)+1 idstr=idstr&rndNum&"," next idstr=idstr+"0" sql="select top 25 ID, * from table where ID in ("+idstr+")" rs.open sql,cn %>

Sunday, July 02, 2006

asp smartupload subscript out of range

you are using smart upload for uploading a file to the server and you get this ugly erro message "asp smartupload subscript out of range" and i'm sure that you didn't write the uploading script.. well, i spent one whole day with this error, and a got angry when i knew that it's a stupid mistake. just look at the html form the the data sent from, you shoud set the enctype to multipart/form-data

that's all!!