M
Miranda
Hi, I have a ASP/vbscript program that generates random passwords. The
problem is I need to insert those passwords into an Access database of
327 clients.
I have the random password program generating the 327 passwords, but
have had no luck inserting them.
===============================================
Here is the code that generates the passwords:
===============================================
<% Option Explicit %>
<%
Dim X
Response.Write "<HTML>" & vbCrLf
Response.Write "<HEAD>" & vbCrLf
Response.Write "<TITLE> ASP Random Password Generator v1.1 - by Carl
Mercier ([email protected])</TITLE>" & vbCrLf
Response.Write "</HEAD>" & vbCrLf
Response.Write "<BODY>" & vbCrLf
Response.Write "<FONT FACE=COURIER>" & vbCrLf
Response.Write "<B>Fixed length (5 character) passwords</B><BR>" &
vbCrLf
For X = 0 To 326
'Response.Write RandomPW(5) & "<br>" & vbCrLf
Next
Response.Write "</FONT>" & vbCrLf
Response.Write "</BODY>" & vbCrLf
Response.Write "</HTML>" & vbCrLf
Function RandomPW(myLength)
'These constant are the minimum and maximum length for random
'length passwords. Adjust these values to your needs.
Const minLength = 5
Const maxLength = 5
Dim X, Y, strPW
If myLength = 0 Then
Randomize
myLength = Int((maxLength * Rnd) + minLength)
End If
For X = 1 To myLength
'Randomize the type of this character
Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase
Select Case Y
Case 1
'Numeric character
Randomize
strPW = strPW & CHR(Int((9 * Rnd) + 48))
Case 2
'Uppercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 65))
Case 3
'Lowercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 97))
End Select
Next
RandomPW = strPW
End Function
%>
===============================================
I tried:
===============================================
Response.Write "<B>Fixed length (5 character) passwords</B><BR>" &
vbCrLf
Response.Write "<form method='post'
action='insertPasswordsADMIN.asp'>" & vbCrLf
For X = 0 To 326
'Response.Write RandomPW(5) & "<br>" & vbCrLf
Response.Write "<input type='text' name='GenPassWord'
value='RandomPW(5)'>"& vbCrLf
Next
Response.Write "<input type='submit' name='update' value='Update'>"&
vbCrLf
Response.Write "</form>" & vbCrLf
===============================================
....with no luck.
===============================================
===============================================
Here is my code for 'insertPasswordsADMIN.asp':
===============================================
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../adojavas.inc"-->
<%
var conn;
var rs;
var sSQL;
rs=Server.CreateObject("ADODB.Recordset");
conn = Server.CreateObject("ADODB.connection");
conn.Open("mydata");
sSQL = "SELECT InvestPassword ";
sSQL += " FROM invest ; "
rs.Open(sSQL,conn);
//Response.write(sSQL);
if (!rs.eof) {
while (!rs.eof){
sSQL += " Insert INTO invest ";
sSQL += " (InvestPassword)";
//expecting values
sSQL += " VALUES ("
sSQL += " '" + Request.form("GenPassWord") + "');"
rs = conn.Execute(sSQL);
rs.MoveNext();
}
}
%>
===============================================
....This line 'rs = conn.Execute(sSQL);' is coughing up an error??
===============================================
Now, one of my problems is that the password generator is in VBScript,
and I code in JavaScript. Although I have some understanding of
VBscript from having to translate it into JavaScript - I am definately
not a pro.
My alternative to figuring this out is inserting the passwords into
the database manually, I'd REALLY rather not do that!
Any Suggestions would be greatly appreciated!!
Thank you in advance for anybody who would like to help me tackle this
problem!
Miranda Johnsen
problem is I need to insert those passwords into an Access database of
327 clients.
I have the random password program generating the 327 passwords, but
have had no luck inserting them.
===============================================
Here is the code that generates the passwords:
===============================================
<% Option Explicit %>
<%
Dim X
Response.Write "<HTML>" & vbCrLf
Response.Write "<HEAD>" & vbCrLf
Response.Write "<TITLE> ASP Random Password Generator v1.1 - by Carl
Mercier ([email protected])</TITLE>" & vbCrLf
Response.Write "</HEAD>" & vbCrLf
Response.Write "<BODY>" & vbCrLf
Response.Write "<FONT FACE=COURIER>" & vbCrLf
Response.Write "<B>Fixed length (5 character) passwords</B><BR>" &
vbCrLf
For X = 0 To 326
'Response.Write RandomPW(5) & "<br>" & vbCrLf
Next
Response.Write "</FONT>" & vbCrLf
Response.Write "</BODY>" & vbCrLf
Response.Write "</HTML>" & vbCrLf
Function RandomPW(myLength)
'These constant are the minimum and maximum length for random
'length passwords. Adjust these values to your needs.
Const minLength = 5
Const maxLength = 5
Dim X, Y, strPW
If myLength = 0 Then
Randomize
myLength = Int((maxLength * Rnd) + minLength)
End If
For X = 1 To myLength
'Randomize the type of this character
Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase
Select Case Y
Case 1
'Numeric character
Randomize
strPW = strPW & CHR(Int((9 * Rnd) + 48))
Case 2
'Uppercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 65))
Case 3
'Lowercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 97))
End Select
Next
RandomPW = strPW
End Function
%>
===============================================
I tried:
===============================================
Response.Write "<B>Fixed length (5 character) passwords</B><BR>" &
vbCrLf
Response.Write "<form method='post'
action='insertPasswordsADMIN.asp'>" & vbCrLf
For X = 0 To 326
'Response.Write RandomPW(5) & "<br>" & vbCrLf
Response.Write "<input type='text' name='GenPassWord'
value='RandomPW(5)'>"& vbCrLf
Next
Response.Write "<input type='submit' name='update' value='Update'>"&
vbCrLf
Response.Write "</form>" & vbCrLf
===============================================
....with no luck.
===============================================
===============================================
Here is my code for 'insertPasswordsADMIN.asp':
===============================================
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../adojavas.inc"-->
<%
var conn;
var rs;
var sSQL;
rs=Server.CreateObject("ADODB.Recordset");
conn = Server.CreateObject("ADODB.connection");
conn.Open("mydata");
sSQL = "SELECT InvestPassword ";
sSQL += " FROM invest ; "
rs.Open(sSQL,conn);
//Response.write(sSQL);
if (!rs.eof) {
while (!rs.eof){
sSQL += " Insert INTO invest ";
sSQL += " (InvestPassword)";
//expecting values
sSQL += " VALUES ("
sSQL += " '" + Request.form("GenPassWord") + "');"
rs = conn.Execute(sSQL);
rs.MoveNext();
}
}
%>
===============================================
....This line 'rs = conn.Execute(sSQL);' is coughing up an error??
===============================================
Now, one of my problems is that the password generator is in VBScript,
and I code in JavaScript. Although I have some understanding of
VBscript from having to translate it into JavaScript - I am definately
not a pro.
My alternative to figuring this out is inserting the passwords into
the database manually, I'd REALLY rather not do that!
Any Suggestions would be greatly appreciated!!
Thank you in advance for anybody who would like to help me tackle this
problem!
Miranda Johnsen