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

Amending Details via sessions

Status
Not open for further replies.

kaycee79

Technical User
Jan 10, 2004
82
GB
I am trying to let a user change their details via the sessions (the session in use is called 'Username')
I have got the form that produces the users details from the database, but the code that changes the details
is causing me a problem, it produces this error message;

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/new/changedetails1.asp, line 25, column 62
sql=&quot;select * from RegisteredUsers where Username=<%=Session(&quot;Username&quot;)
-------------------------------------------------------------^

I am not sure how to correct this, can anyone help?

Thanks in Advance

Code:
<!--#include file = &quot;clock.inc&quot; -->

<HTML>
<HEAD>
<TITLE>Amend Details</TITLE>
</HEAD>

<BODY>
<div id=&quot;content&quot;>

<input type=&quot;button&quot; onClick=&quot;document.all.content.style.zoom=(document.all.content.style.zoom==1?2:1);&quot; value=&quot;Change Font Size&quot;>

<body onload=&quot;StartClock()&quot; onunload=&quot;KillClock()&quot;>
<form name=&quot;theClock&quot; action=&quot;changedetails1.asp&quot; METHOD=&quot;post&quot;>
    <input type=&quot;text&quot; name=&quot;theTime&quot; size=6><% Response.Write Date %>


<H1><U><B>Amend Details</U></B></H1>





<BR>
Title <input type=&quot;text&quot; name=&quot;txtNewTitle&quot; size=&quot;20&quot; value=&quot;<%=Session(&quot;Title&quot;)%>&quot;><br>
First Name <input type=&quot;text&quot; name=&quot;txtNewFirstName&quot; size=&quot;20&quot; value=&quot;<%=Session(&quot;First Name&quot;)%>&quot;><br>
Surname <input type=&quot;text&quot; name=&quot;txtNewSurname&quot; size=&quot;20&quot; value=&quot;<%=Session(&quot;Surname&quot;)%>&quot;><br>
Address 1 <input type=&quot;text&quot; name=&quot;txtNewAddress1&quot; size=&quot;20&quot; value=&quot;<%=Session(&quot;Address 1&quot;)%>&quot;><br>
Address 2 <input type=&quot;text&quot; name=&quot;txtNewAddress2&quot; size=&quot;20&quot; value=&quot;<%=Session(&quot;Address 2&quot;)%>&quot;><br>
Town <input type=&quot;text&quot; name=&quot;txtNewTown&quot; size=&quot;20&quot; value=&quot;<%=Session(&quot;Town&quot;)%>&quot;><br>
County <input type=&quot;text&quot; name=&quot;txtNewCounty&quot; size=&quot;20&quot; value=&quot;<%=Session(&quot;County&quot;)%>&quot;><br>
Post Code <input type=&quot;text&quot; name=&quot;txtNewPostCode&quot; size=&quot;20&quot; value=&quot;<%=Session(&quot;Post Code&quot;)%>&quot;><br>
Email Address <input type=&quot;text&quot; name=&quot;txtNewEmailAddress&quot; size=&quot;20&quot; value=&quot;<%=Session(&quot;EmailAddress&quot;)%>&quot;><br>
Telephone Number <input type=&quot;text&quot; name=&quot;txtNewTelephoneNo&quot; size=&quot;20&quot; value=&quot;<%=Session(&quot;Telephone Number&quot;)%>&quot;><br>
<BR>
<input type=&quot;Submit&quot; name=&quot;Submit&quot; value=&quot;Submit my New Details&quot;><BR>
<input type=&quot;Reset&quot; name=&quot;Reset&quot; value=&quot;Clear&quot;>

</div>
</BODY>
</html>

Code:
<!-- #include file=&quot;clock.inc&quot; -->

<!-- #include file=&quot;ProjectConnection.asp&quot; -->

<!-- METADATA TYPE=&quot;typelib&quot;
              FILE=&quot;c:\Program Files\Common Files\System\ado\msado15.dll&quot; -->




<html>
<head>
<body>
<div id=&quot;content&quot;>
<input type=&quot;button&quot; onClick=&quot;document.all.content.style.zoom=(document.all.content.style.zoom==1?2:1);&quot; value=&quot;Change Font Size&quot;>

<body onload=&quot;StartClock()&quot; onunload=&quot;KillClock()&quot;>
<form name=&quot;theClock&quot;>
    <input type=text name=&quot;theTime&quot; size=6><% Response.Write Date %><BR>

<%
    	Dim objRS, strConnect
    	
	Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
    	sql=&quot;select * from RegisteredUsers where Username=<%=Session(&quot;Username&quot;)%>&quot;
	objRS.Open sql, strConnect, 3,3
	
	
	
    	objRS.Fields(&quot;Title&quot;) = Request.Form(&quot;txtNewTitle&quot;)
	objRS.Fields(&quot;First Name&quot;) = Request.Form(&quot;txtNewFirstName&quot;)
	objRS.Fields(&quot;Surname&quot;) = Request.Form(&quot;txtNewSurname&quot;)
	objRS.Fields(&quot;Address 1&quot;) = Request.Form(&quot;txtNewAddress1&quot;)
	objRS.Fields(&quot;Address 2&quot;) = Request.Form(&quot;txtNewAddress2&quot;)
	objRS.Fields(&quot;Town&quot;) = Request.Form(&quot;txtNewTown&quot;)
	objRS.Fields(&quot;County&quot;) = Request.Form(&quot;txtNewCounty&quot;)
	objRS.Fields(&quot;Post Code&quot;) = Request.Form(&quot;txtNewPostCode&quot;)
	objRS.Fields(&quot;Telephone Number&quot;) = Request.Form(&quot;txtNewTelephoneNo&quot;)
	objRS.Fields(&quot;EmailAddress&quot;) = Request.Form(&quot;txtNewEmailAddress&quot;)
	
    	
	objRS.Close
    	Set objRS = Nothing
    	

%> 



</div>
</body>
</html>
 
you build the SQL statement within a <% %> block
so change

sql=&quot;select * from RegisteredUsers where Username=<%=Session(&quot;Username&quot;)%>&quot;


into

sql=&quot;select * from RegisteredUsers where Username='&quot; &_
Session(&quot;Username&quot;) & &quot;'&quot;



hth,
Foxbox
ttmug.gif
 
Tried it, and now i have another problem;
This is the message i am getting now

Error Type:
ADODB.Recordset (0x800A0C93)
Operation is not allowed in this context.
/new/changedetails1.asp, line 43

Line 43 is
objRS.Close
 
Dont forget to Update your recordset object...
The last code lines should look like this
Code:
objRS.Fields(&quot;EmailAddress&quot;) = Request.Form(&quot;txtNewEmailAddress&quot;)
   objRS.Update
   if objRS.State=1 then objRS.Close
   'State=1 means opened RS
   Set objRS = Nothing

________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top