随机生产10位数字作为用户唯一ID,如果确保不重复?
dim user_id,total,f_all,f_Rand_a,f_Randomizecode,f_iR
Function GetRamCode(f_number)
Randomize
f_all="1|2|3|4|5|6|7|8|9" '共9个
f_Rand_a=split(f_all,"|")
for f_iR=1 to f_number
f_Randomizecode=f_Randomizecode&f_Rand_a(Int((9*Rnd)))
next
user_id=f_Randomizecode
'response.Write (info_url)
do
set rs3=server.createobject("adodb.recordset")
rs3.open "select count(*) as total from date_user where user_id='"&user_id&"'",MM_con_user_STRING,1,3
if rs3("total")=0 then '说明数据库里没有,可以添加 然后退出 do
user_id=user_id
exit do
rs3.close
set rs3=nothing
end if
call GetRamCode(10)'重新生产10位数
loop while true
End Function
call GetRamCode(10)
这是我编的,但是有问题啊 ,效率低啊!
请高手看下,希望不要用那种 日期加时间 生产用户唯一ID 还有这种md5(yymmdd)也不太好