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

I can't get my password change script to work

Status
Not open for further replies.

TJunior

IS-IT--Management
Jan 18, 2002
33
DE
I'm having some problems with my script for changing a password in my application. I have attched both the script and error message below, and would be very grateful if you could have a look at my script to se where I am going wrong.

<%
Dim objconn, objRS, strconn, strout, strQ
Dim loginField, passwordField

loginField = Request.Form(&quot;login&quot;)
passwordField = Request.Form(&quot;password&quot;)

Set objconn = Server.CreateObject(&quot;ADODB.Connection&quot;)
strconn = &quot;DSN=Worry-not; Database=tdotcom;&quot;
strconn = strconn & &quot;UID=;PWD=;&quot;
objconn.Open strconn

Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Set objRS.ActiveConnection = objconn

strQ = &quot;SELECT * FROM Password &quot;
strQ = strQ & &quot;WHERE Username = '&quot; &loginField& &quot;' AND Passwd = '&quot; & Request.Form(&quot;oldpassword&quot;) & &quot;' &quot;
strQ = strQ & &quot;AND '&quot; & Request.Form(&quot;newpassword1&quot;) = Request.Form(&quot;newpassword2&quot;) & &quot;' &quot;
objRS.Open strQ <<<***This is Line 19***>>>


If Request.Form(&quot;login&quot;) = objRS(&quot;Username&quot;) AND Request.Form(&quot;oldpassword&quot;) = objRS(&quot;Passwd&quot;) AND Request.Form(&quot;newpassword1&quot;) = Request.Form(&quot;newpassword2&quot;) then
SQL = &quot;UPDATE Password SET Passwd = '&quot; & Request.Form(&quot;newpassword2&quot;) & &quot;' WHERE Username = '&quot; & Request.Form(&quot;login&quot;) & &quot;'&quot;
objconn.Execute(SQL)
Response.redirect (&quot;updated.asp&quot;)
Else
Response.redirect (&quot;passchange2.asp&quot;)
End if

objRS.Close
objconn.Close
Set objRS = Nothing
Set objconn = Nothing
%>

This is the error that I get:-

Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/Project1_Local/passchange1.asp, line 19

Thank you for your time.
 
strQ = strQ & &quot;AND '&quot; & Request.Form(&quot;newpassword1&quot;) = Request.Form(&quot;newpassword2&quot;) & &quot;' &quot;

you can't compare your form input to each other in the sql statement. do this before you go to the database, then if newpassword1 <> newpassword2, you don't even access the db, you just spit out your error.
 
Thanks for that. I wasn't sure if you could compare for input fields and actually forgot to mention that in the beginning. I have sorted the problem. Thanx again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top