日期:2014-05-16  浏览次数:21054 次

如何批量增加500个礼券卡号吗?
谁能本我看看如何批量一次性生成500个不同的卡号

<%
'批量生成礼券卡号
if request("action")="save" and request("action") <> empty then
arrName=500
For i = 0 to Ubound(arrName) 
password=request.form("password")
set rs=server.createobject("adodb.recordset")
sql="select * from test"
rs.open sql,conn,1,3
rs.addnew
shuzi=cstr(Int((9999 - 1000 + 1) * Rnd() + 1000))
'Conn.execute("insert into product(prname) values('"&Trim(arrName(i))&"')") 
rs("username")="&shuzi$i&"
'rs("grade")=request.form("grade")

Next
rs.update
response.write"<Script Language=Javascript>window.alert('成功生成!');location.href='index.asp';</Script>"
response.end
rs.close
set rs=nothing
end if%>

这个是我随便写的。但是不正确

------解决方案--------------------
引用:
2楼的silinee  你的这个程序可以实现,但是我有个疑问,就是怎能保证礼券的卡号不重复,如果生成上万个呢!会不会有重复啊
二楼能不生成不知道,但知道那个随机号是一样的,因为没有randomize
我的代码生成不了,只是写错一个单词
if Conn.execute("select count(prname) form [product] where prname='"&code&"'")(0)>0 then
改为:
if Conn.execute("select count(prname) from [product] where prname='"&code&"'")(0)>0 then
============已经经过测试,不会重号。