网页产生随机数写进数据库但显示的结果和数据库中的结果竟不一样。。。。。
这是一段产生随机数代码,,,写进数据库结果和产生的随机数不相同?为什么?<%
dim Conn
dim dbpath
dbpath=server.MapPath("datebase/21asp.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
conn.open "provider=microsoft.jet.oledb.4.0; data source="&DBpath
'Conn.Open "driver={ Microsoft Access Driver (*.mdb)};Pwd=;dbq=" & dbpath
for i = 1 to 2
Response.Write i&"<br>"&gen_key(1)&"<br>"
sql = "insert into [Sheet1$]values('"&i&"','"& gen_key(1) &"')"
conn.Execute(sql)
Next
Function gen_key(digits)
dim char_array(50)
char_array(0) = "0"
char_array(1) = "1"
char_array(2) = "2"
char_array(3) = "3"
char_array(4) = "4"
char_array(5) = "5"
char_array(6) = "6"
char_array(7) = "7"
char_array(8) = "8"
char_array(9) = "9"
char_array(10) = "A"
char_array(11) = "B"
char_array(12) = "C"
char_array(13) = "D"
char_array(14) = "E"
char_array(15) = "F"
char_array(16) = "G"
char_array(17) = "H"
char_array(18) = "I"
char_array(19) = "J"
char_array(20) = "K"
char_array(21) = "L"
char_array(22) = "M"
char_array(23) = "N"
char_array(24) = "O"
char_array(25) = "P"
char_array(26) = "Q"
char_array(27) = "R"
char_array(28) = "S"
char_array(29) = "T"
char_array(30) = "U"
char_array(31) = "V"
char_array(32) = "W"
char_array(33) = "X"
char_array(34) = "Y"
char_array(35) = "Z"
randomize
do while len(output) < digits
num = char_array(Int((35 - 0 + 1) * Rnd + 0))
output = output + num
loop
gen_key = output
End Function
%>
页面显示结果为 1:R
2:G
但数据库中结果竟为1:O
2:U
为什么〉?