asp生成随机字符串!不重复,要数据库帮忙
只能把生成的记录放到数据库里面了
<!--#include file=conn.asp -->
<%
Function getCode(iCount)
Dim arrChar
Dim j,k,strCode
arrChar = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
k=Len(arrChar)
Randomize
For i=1 to iCount
j=Int(k * Rnd )+1
strCode = strCode & Mid(arrChar,j,1)
Next
getCode = strCode
End Function
for kk=1 to 10
ssjm=getCode(7)
set rs=server.CreateObject("adodb.recordset")
exec="select top 1 * from websjm where sjm='"&ssjm&"'"
rs.open exec,conn,1,3
if rs.eof then
rs.addnew
rs("sjm")=ssjm
rs.update
end if
response.write ssjm&"<br />"
response.flush()
next
%>
<%
Function getCode(iCount)
Dim arrChar
Dim j,k,strCode
arrChar = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
k=Len(arrChar)
Randomize
For i=1 to iCount
j=Int(k * Rnd )+1
strCode = strCode & Mid(arrChar,j,1)
Next
getCode = strCode
End Function
for kk=1 to 10
ssjm=getCode(7)
set rs=server.CreateObject("adodb.recordset")
exec="select top 1 * from websjm where sjm='"&ssjm&"'"
rs.open exec,conn,1,3
if rs.eof then
rs.addnew
rs("sjm")=ssjm
rs.update
end if
response.write ssjm&"<br />"
response.flush()
next
%>
离开了你,我注定孤独
很多事!网站的广告难做!
