Originariamente inviato da optime
ovviamente la seconda che hai detto
Grazie, al momento non posso provare il controllo che ho scritto così, è corretto posso ottimizarlo?
codice:
nr_random = request.form("nr_random")
Sql = "SELECT * from Trsfrt where nr_random = '"& nr_random &"'"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open SQL, conn, 3, 3
if objRS.eof then
nr_random = request.form("nr_random")
else
Function RandomPW(myLength)
Const minLength = 6
Const maxLength = 20
Dim X, Y, strPW
If myLength = 0 Then
Randomize
myLength = Int((maxLength * Rnd) + minLength)
End If
For X = 1 To myLength
Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase
Select Case Y
Case 1
Randomize
strPW = strPW & CHR(Int((9 * Rnd) + 48))
Case 2
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 65))
Case 3
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 97))
End Select
Next
RandomPW = strPW
End Function
strfinal = RandomPW(12)
nr_random = strfinal
end if
objRS.close
set objRS = nothing