<%
'Our Function generatePassword accepts one parameter 'passwordLength'
'passwordLength will obviously determine the password length.
'The aplhanumeric character set is assigned to the variable sDefaultChars
Function generatePassword(passwordLength)
'Declare variables
Dim sDefaultChars
Dim iCounter
Dim sMyPassword
Dim iPickedChar
Dim iDefaultCharactersLength
Dim iPasswordLength
'Initialize variables
sDefaultChars="abcdefghijklmnopqrstuvxyzABCDEFGHIJ KLMNOPQRSTUVXYZ0123456789"
iPasswordLength=passwordLength
iDefaultCharactersLength = Len(sDefaultChars)
Randomize'initialize the random number generator
'Loop for the number of characters password is to have
For iCounter = 1 To iPasswordLength
'Next pick a number from 1 to length of character set
iPickedChar = Int((iDefaultCharactersLength * Rnd) + 1)
'Next pick a character from the character set using the random number iPickedChar
'and Mid function
sMyPassword = sMyPassword & Mid(sDefaultChars,iPickedChar,1)
Next
generatePassword = sMyPassword
End Function
%>
<%
set connection = Server.CreateObject("ADODB.Connection")
Connection.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source=" & Server.MapPath(".\db1.mdb")
Set Recordsx = CreateObject("ADODB.Recordset")
sqltemp = "SELECT * FROM soci WHERE password is null"
Recordsx.Open sqltemp, Connection,2,3
dim password
i=0
Do While not Recordsx.eof
data_source = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source=" & Server.MapPath(".\db1.mdb")
password = generatePassword(8)
update_query = "UPDATE soci SET password='" & password & "' WHERE password is null"
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute update_query
con.Close
Set con = Nothing
loop
Recordsx.close
set Recordsx = Nothing
%>