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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP script loading very slow...

Status
Not open for further replies.

Phailak

Programmer
Apr 10, 2001
142
CA
Hail,

Just a quick question. I set up my WIN98 with PWS but when I run my ASP scripts, it works fine the first time, but if I reload them a second time, the progress bar slows down a lot and just doesn't load the second part of the script. I use the same ones at work on NT server and it works fine. Could it simply be my config or what?
As for the scripts, it's basic stuff, user enters a userID and password and presses login button, then the script verify the password in a access database through ODBC.

Phailak
 
I think we need to see some of the basic stuff. The strange thing is that it runs oke the first time, and then slows down, and the same script runs oke on NT-server.... br
Gerard
(-:

Better a known bug then a new release.
 
You might not be destroying your connection and recordset objects.

I know they are "supposed" to be stateless, but it's been my experience that NT or Win2K environments handle this better than PWS if you forget to close and destroy the objects when the page is finished... especially when those objects (the connection, in particular) is referring to an Access backend (rather than SQL Server) --

To do this, add this code to the bottom of your page:

set connObject = nothing
set recordsetObject = nothing

Obviously, replacing the connObject and recordsetObject with the actual names of your objects.

good luck! :)
Paul Prewett
 
Well here are the two srcipts...

Default.asp:

<%@ Language=VBScript %>

<HTML>

<%
dim sql, conn, PWD, UID, EntPWD
Response.Write &quot;<form name=frmTT method=post action=Login.asp>&quot;
%>

<head>
<title>Gladiators</title>
</head>

<body text=&quot;#000000&quot; bgcolor=&quot;#C0C0C0&quot; link=&quot;#0000EE&quot; vlink=&quot;#FFFF99&quot; alink=&quot;#FF0000&quot;>

<center><font size=+4>Gladiators</font><font size=+4></font>
<p><font size=+2>Your nostrils fill with the scent of blood and sweat.
Your eyes focus on your enemy's blade. Your ears rejoyce in your opponent's
screams of agony. Your mouth waters in anticipation of victory. The crowds.
The cheers. </font><font size=+3>VICTORY...</font><font size=+3></font>
<p><font size=+2>Your nostrils struggle to breathe. Your eyes are blinded
by the blood flowing from your brow. Your ears shy away from your
enemy's taunts. Your mouth fills with blood, drowning you in defeat. The
crowds. The cheers. </font><font size=+3>DEFEAT...</font><font size=+3></font>
<p><font size=+2>Be it one or the other, GLORY or SHAME, you ARE destined
to be a...</font><font size=+2></font>
<p><font size=+4>Gladiator</font><font size=+4></font>
<br>
<p><font size=+4>UserID:</font><font size=+4></font>
<br><br>
<div align=&quot;center&quot;><input type=&quot;text&quot; name=&quot;txtUserID&quot; value=&quot;&quot; size=&quot;15&quot; maxlength=&quot;15&quot;></div>
<br>
<p><font size=+4>Password:</font></center>
<br><br>
<div align=&quot;center&quot;><input type=&quot;password&quot; name=&quot;txtPassword&quot; value=&quot;&quot; size=&quot;15&quot; maxlength=&quot;15&quot;></div>
<br><br><br><br>

<div align=center><input type=submit name=cmdLogin value=Login></div><br><br>
</body></form></html>


Login.ASP:

<body text=&quot;#000000&quot; bgcolor=&quot;#C0C0C0&quot; link=&quot;#0000EE&quot; vlink=&quot;#FFFF99&quot; alink=&quot;#FF0000&quot;>
<%
if Request.Form(&quot;cmdLogin&quot;) <> &quot;&quot; then

UID = request.form(&quot;txtUserID&quot;)
EntPWD = request.form(&quot;txtPassword&quot;)
sql = &quot;select top 1 password, UserID from players Where UserID = '&quot; & UID & &quot;'&quot;
Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open &quot;Glad&quot;
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open sql, Conn

if not rs.EOF then
PWD = rs(&quot;Password&quot;)
if PWD = EntPWD then
Response.Write &quot;Correct&quot;
else
Response.Write &quot;<head><title>Gladiators</title></head>&quot;
Response.Write &quot;<center><font size=+4>Incorrect Password, try again</font>&quot;
end if
else
PWD = &quot;No such User, try again&quot;
Response.Write &quot;<head><title>Gladiators</title></head>&quot;
Response.Write &quot;<center><font size=+4>&quot; & PWD & &quot;</font>&quot;
end if

rs.Close
conn.Close
set conn = nothing
set rs = nothing

end if
%>


Anything?

Phailak
 
Some remarks:

1. Default.asp is plain HTML. There is no need to response.write the <FORM> line;
2. You do not need DIM in default.asp;
3. Tou can simply sumbit the form without a value.


<%@ Language=VBScript %>
<html>
<form name=frmTT method=post action=Login.asp>
UserID:
<input type=&quot;text&quot; name=&quot;txtUserID&quot; value=&quot;&quot; size=&quot;15&quot; maxlength=&quot;15&quot;>
Password:
<input type=&quot;password&quot; name=&quot;txtPassword&quot; value=&quot;&quot; size=&quot;15&quot; maxlength=&quot;15&quot;>
<input type=submit value=Login>
</form>
</html>




4. i would test if userid and password were entered
5. Maybe it is wise to convert the UID's
6. There is no need to select the UserID
7. You sometime write something before the <head>
8. There is no need to store someting in PWD in order to
print an error msg



<%
DIM UID, EntPWD, lCorrect
lCorrect = false
UID = ucase(request.form(&quot;txtUserID&quot;))
EntPWD = request.form(&quot;txtPassword&quot;)
if UID=&quot;&quot; or EntPWD=&quot;&quot; then
' back to login screen
response.redirect &quot;default.asp&quot;
response.end
end if

sql = &quot;select top 1 password from players &quot; &_
&quot;where UserID = '&quot; & UID & &quot;'&quot;
Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open &quot;Glad&quot;
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open sql, Conn

if not rs.EOF then
if rs(0) = EntPWD then
lCorrect = true
else
alert(&quot;Incorrect Password, try again&quot;)
end if
else
alert(&quot;User unknown&quot;)
end if

rs.Close
conn.Close
set conn = nothing
set rs = nothing

if lCorrect then
response.redirect &quot;menu.asp&quot;
else
response.redirect default.asp&quot;
end if
%>



[the above was not tested (its the first real sunny day and i'm sitting in the sun; i typed it in on the fly]




br
Gerard
 
Hail,

Thanx for the example, I am having a problem with the line Alert, I get error message saying type mismatch. Since I don't really have any experience, I'm sure it's something real simple, but it got me stuck anyway, is it suppose to be like a msgbox function or something?

Phailak
 
Yep you're right: alert is another language. We want to warn our user and than direct him/her to default.asp.

response.redirect &quot;warning.asp?text=&quot;&quot;Incorrect Password, try again&quot;&quot;&quot;

in warning.asp you accept the (variable) text with
a OK-button.
After pressing the button you direct your user to default.asp.

In my application i've made a very general warning.page, that is accepting an error-code. The warning-page searches a database for the text AND the button(s) [OK/ Cancel/ etc] and the actions per button. But that is because i'm very lazy.
br
Gerard
 
Hail,

Ok, I get the concept, but how do I retrieve the variable from pressing on the ok button. Like before I got it by request.form but what about in this case?

Phailak
 
It is better not to use text as a variable, so i changed to errmsg. warning.asp:

response.write &quot;<html><body>&quot;
response.write &quot;<form name=frmWarning method=post &quot; &_
&quot;action=default.asp>&quot; &_
request.querystring(&quot;errmsg&quot;) &_
&quot;<br><input type=submit value=OK> &_
&quot;</form></body></html>&quot;


so in login.asp we call warning.asp with the parameter errmsg. in warning.asp you must querystring to retrieb the value. warning.asp is a form that will start default.asp when the user presses the OK-button.



br
Gerard
 
Hail,

Well thanx for all the help, I learned a lot, problem is, everything worked fine from here, but when I got home and tried it, same situation aroused, worked the first time, then second time the default page doesn't load, I only see the progress bar bottom right slowly reaching half way before stopping completly!
If I do back instead of relaoding the page, the default page comes back but when I try to log in, same situation with progress bar...

Any thoughts?

Phailak
 
no.
are you testing with the simple version scripts (like the one above)? if no: try that first (create a copy set, remove all the fancy stuff). if yes: i'm out of ideas (i work win2k + iis).
br
Gerard
 
Hi Guys,
I am also getting a same problem with PWS on Win98 machine,
Progress bar is slowly incrementing and at certain stage it's stoping,it's only happening when we started loading aftere first file,

Is there any solution please let me know ,

I DON&quot;T THINK WE HAVE A SOLUTION FOR THIS IN WIN 98/95.

THE ONLY SOLUTION I FOUND IS CHANGING THE OS WIN2000/NT IS THE BEST FOR EXECUTING THE ASP PAGES.

bye,
vans
 
I was having the same problem with PWS regarding multiple page calls. If you are running Antivirus software, try disabling it while you're dong local testing. I mean - as long as you aren't online, you should be fine.

If this doesn't solve it for you, I don't know what to tell you. My workaround was to right click PWS in the tray, hit stop then hit start again. I know that it's a hassle, since you lose all your session variables (if you have any) and you have to restart PWS, but it halted execution and enabled me to test things out. Also - if you hit stop (to stop loading the page in your browser), then refresh it, it will allow you to run the page, but then PWS starts keeping open connections for each page that hung. PWS has a 10 active connection maxximum, so in no time you'll start getting maxximum connection errors.

hope this helps,
leo
 
Hail,

That is really bad. I mean, I don't want to run NT, I have it at work, home is for the games ;O)
As for 2000, I had several problems when I installed it and my DSL service doesn't support it...
So I'm stuck with WIN98 but I can't believe it's so complicated, I'm just testing the darn thing, not running it???
Anyway, I guess I'll have to live with it.

Phailak
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top