Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays and Global.asa 1

Status
Not open for further replies.

tmigliorino

Programmer
Jan 23, 2002
2
In the code below I only get the last 'clientPic', doesn't seem to be creating an array. Should I be using redim in my code?

The customer.asp script is used to display the pictures from the picture names in the 'clientPic' array.

I am using ASP3 not ASP.Net.

<%
dim i, clientLogIn, clientPwd, oRs

clientLogIn = request("clientName")
clientPwd = request("clientPwd")
clientValid = false
i = 0
session("clientPW") = ""
session("clientPic()") = ""
session("clientName") = ""

Set oRs = Server.CreateObject("ADODB.Recordset")

With oRs
.open "qryValidateUserAndPassword", application("appDataSource"), adOpenStatic, adLockOptimistic
do while not .EOF
if lcase(trim(.fields("UserName"))) = lcase(trim(clientLogIn)) then
i = i + 1
session("clientPW") = trim(.fields("Password"))
session("clientPic(i)") = trim(.fields("FileName"))
session("clientName") = trim(.fields("FName"))
if len(trim(.fields("MInitial"))) > 0 then
session("clientName") = session("clientName") & " " & trim(.fields("MInitial"))
end if
session("clientName") = session("clientName") & " " & trim(.fields("LName"))
if lcase(trim(.fields("Password"))) = lcase(trim(clientPwd)) then
clientValid = true
end if
end if
.movenext
loop
if session("clientName") = "" then
session("clientName") = "Unknown User"
elseif clientValid then
response.redirect "customers.asp"
end if
End with
%>
 
Not sure if I understand the idea.
[tt]
'etc etc
i=[red]-1[/red] 'depends on the position of i=i+1 later
[red]'[/red]session("clientPic()") = ""
[blue]session("clientPic")=Array()[/blue]
'etc etc
do while not .EOF
if lcase(trim(.fields("UserName"))) = lcase(trim(clientLogIn)) then
i = i + 1
session("clientPW") = trim(.fields("Password"))
[blue]redim preserve [session("clientPic")](i)[/blue]
[red]'[/red]session("clientPic(i)") = trim(.fields("FileName"))
[blue][session("clientPic")](i) = trim(.fields("FileName"))[/blue]
session("clientName") = trim(.fields("FName"))
if len(trim(.fields("MInitial"))) > 0 then
session("clientName") = session("clientName") & " " & trim(.fields("MInitial"))
end if
session("clientName") = session("clientName") & " " & trim(.fields("LName"))
if lcase(trim(.fields("Password"))) = lcase(trim(clientPwd)) then
clientValid = true
end if
end if
.movenext
loop
'etc etc
[/tt]
You can refer to the session("clientPic") later by index such as [session("clientPic")](index) etc.
 
Thank you tsuji. I will try this and let you know the outcome.

By the way this code is to collect and verify user name and password for a client, and to collect photographs that my wife has restored. The client can look at the results and make comments with out coming to our house or using e-mail.

The program customer.asp will loop through the array and display the photographs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top