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!

update query not working

Status
Not open for further replies.

vasah20

Programmer
Feb 16, 2001
559
US
hey all -
i was hoping someone here could figure this out...
my update is returning a -1. I'm trying to insert into a memo field (A2K), and what's getting stored is a -1.

I've printed out the sql statement, and got what looks perfect:
Code:
UPDATE users SET profile = 'testing the update i''m doing' AND password = 'mypass' AND email = 'test@hotmail.com' WHERE userpk = 2

the above code runs in query analyzer (or whatever access calls it) perfectly fine.

I've cut and paste my entire page below. I'm thinking it has something to do with permissions, but my setup doesn't have any permissions (Win98, PWS, Access 2K, MDAC 2.5)

The reason I think this is because it won't let me do an insert either....

any suggestions?

Code:
<%Option Explicit
Response.buffer = true

Dim pk, un
pk = Session(&quot;userpk&quot;)
un = Session(&quot;username&quot;)

if pk = &quot;&quot; or un = &quot;&quot; then
	Response.Redirect(&quot;login.asp&quot;)
end if

Sub main(update,pw,pr,em,oldpw)
	Dim c, r
	Set c = Server.CreateObject(&quot;ADODB.Connection&quot;)
	Set r = Server.CreateObject(&quot;ADODB.Recordset&quot;)
	c.Open CN_STRING
	r.ActiveConnection = c

	if update then
		r.Open &quot;SELECT userpk, password FROM users WHERE password = '&quot; & replace(oldpw,&quot;'&quot;,&quot;''&quot;) & &quot;' &quot; & _
			&quot;AND userpk = &quot; & pk

		if r.EOF then
			Response.write &quot;The password you supplied was incorrect. Please try again&quot;
		else
			if pw = &quot;&quot; then
				pw = r(&quot;password&quot;)
			end if

			pw = replace(pw,&quot;'&quot;,&quot;''&quot;)
			if pr = &quot;&quot; then
				pr = &quot; &quot; 
			end if
			
			pr = replace(pr,&quot;'&quot;,&quot;''&quot;)
			Response.write pr
			
			Dim sql
			sql = &quot;UPDATE users SET profile = '&quot; & pr & &quot;' AND password = '&quot; & pw & &quot;' AND &quot; & _
				&quot;email = '&quot; & replace(em,&quot;'&quot;,&quot;''&quot;) & &quot;' WHERE userpk = &quot; & pk 
			Response.write sql & &quot;<hr />&quot;
			Response.Write &quot;<p>Your information has been updated </p><p><a href=&quot;&quot;memberhome.asp&quot;&quot;>members home</a></p>&quot;
		end if
	else
		r.Open &quot;SELECT email,profile FROM users WHERE userpk = &quot; & pk 

		if r.EOF then
			Response.write &quot;We are currently having problems trying to get your information. Please <a href=&quot;&quot;login.asp&quot;&quot;>login again</a>&quot;
		else
			Response.write &quot;<form name=&quot;&quot;update&quot;&quot; action=&quot;&quot;editinfo.asp&quot;&quot; method=&quot;&quot;post&quot;&quot;>&quot; & _
				&quot;<table cellpadding=&quot;&quot;4&quot;&quot; cellspacing=&quot;&quot;0&quot;&quot; border=&quot;&quot;0&quot;&quot;>&quot; & _
				&quot;<input type=&quot;&quot;hidden&quot;&quot; name=&quot;&quot;update&quot;&quot; value=&quot;&quot;true&quot;&quot; />&quot; & _
				&quot;<tr><td>Username:</td><td>&quot; & un & &quot;</td></tr>&quot; & _
				&quot;<tr><td>Email:</td><td><input type=&quot;&quot;text&quot;&quot; class=&quot;&quot;tb&quot;&quot; name=&quot;&quot;em&quot;&quot; size=&quot;&quot;20&quot;&quot; value=&quot;&quot;&quot; & r(&quot;email&quot;) & &quot;&quot;&quot; maxlength=&quot;&quot;255&quot;&quot;</td></tr>&quot; & _
				&quot;<tr><td>New password:</td><td><input type=&quot;&quot;password&quot;&quot; name=&quot;&quot;pw&quot;&quot; size=&quot;&quot;16&quot;&quot; maxlength=&quot;&quot;50&quot;&quot; class=&quot;&quot;tb&quot;&quot; />&quot; & _
				&quot;<tr><td>Retype password:</td><td><input type=&quot;&quot;password&quot;&quot; name=&quot;&quot;retype&quot;&quot; size=&quot;&quot;16&quot;&quot; maxlength=&quot;&quot;50&quot;&quot; class=&quot;&quot;tb&quot;&quot; />&quot; & _
				&quot;<tr><td colspan=&quot;&quot;2&quot;&quot;>Quote:<br /> &nbsp; <textarea name=&quot;&quot;pr&quot;&quot; cols=&quot;&quot;40&quot;&quot; rows=&quot;&quot;10&quot;&quot; class=&quot;&quot;tb&quot;&quot;>&quot; & r(&quot;profile&quot;) & &quot;</textarea></td></tr>&quot; & _
				&quot;<tr align=&quot;&quot;right&quot;&quot;><td colspan=&quot;&quot;2&quot;&quot;>old password: <input type=&quot;&quot;password&quot;&quot; size=&quot;&quot;16&quot;&quot; maxlength=&quot;&quot;50&quot;&quot; class=&quot;&quot;tb&quot;&quot; name=&quot;&quot;oldpass&quot;&quot; />&quot; & _
				&quot;<br><input type=&quot;&quot;reset&quot;&quot; value=&quot;&quot;reset&quot;&quot; class=&quot;&quot;tb&quot;&quot; /><input type=&quot;&quot;submit&quot;&quot; value=&quot;&quot;change&quot;&quot; class=&quot;&quot;btn&quot;&quot; /></td></tr></table>&quot;
		end if
	end if

	r.Close
	c.Close
	Set r = Nothing
	Set c = Nothing
End sub
%>
<!--#include file=&quot;includes\cninfo.asp&quot; -->
<!--#include file=&quot;includes\header.asp&quot; -->
<%Call main(CBool(Request.Form(&quot;update&quot;)),Request.Form(&quot;pw&quot;), _
	Request.Form(&quot;pr&quot;), Request.Form(&quot;em&quot;), Request.Form(&quot;oldpass&quot;)) %>
<!--#include file=&quot;includes\footer.asp&quot; -->

TIA - leo

------------
Leo Mendoza
lmendoza@garbersoft.net
 
I noticed I was missing a c.Execute sql statement, added it - still nothing leo

------------
Leo Mendoza
lmendoza@garbersoft.net
 
found it. password should read [password]. =)
MySQL has made me lazy leo

------------
Leo Mendoza
lmendoza@garbersoft.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top