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

Updating Records(Cont.) 1

Status
Not open for further replies.

Herminio

Technical User
May 10, 2002
189
PT
hi there, i've been posting messages here since yesterday and i just can do what i want.

I want to update records from the form values on one page(detail.asp), the SQL Update is on the sucessfull update page(update.asp).

I'm going to put the code for the two pages here, please help me.

--------------
Detail.asp
--------------
<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<%

dim sColect, conn, sqlSearch

sColect = Request(&quot;Colect&quot;)

%>

<% set conn = Server.CreateObject(&quot;adodb.connection&quot;)
conn.open &quot;dsn=direct&quot;


'Procura na tabela member os dados carregados na variavél strSearch
Set sqlSearch = conn.Execute(&quot;SELECT * FROM member WHERE ((Colect Like '%&quot; & sColect & &quot;%'));&quot;)
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>
<%

dim strColect, strPass, strPass2, strFut, strId

strId = sqlSearch(&quot;Id&quot;)
strColect = sqlSearch(&quot;Colect&quot;)
strPass = sqlSearch(&quot;Password&quot;)
strPass2 = sqlSearch(&quot;Password2&quot;)
strFut = sqlSearch(&quot;Futebol&quot;)

%>
<input type=&quot;hidden&quot; name=&quot;Id&quot; value=&quot;<%=strId%>&quot;>
<table>
<tr>
<td colspan=&quot;2&quot;><div align=&quot;center&quot;><font size=&quot;5&quot;><em><strong>Dados da
Colectividade</strong></em></font></div></td>
</tr>
<tr>
<td width=&quot;173&quot;><strong>Nome:</strong></td>
<td width=&quot;108&quot;>
<input name=&quot;Colect&quot; type=&quot;text&quot; value=&quot;<%=strColect%>&quot; disabled size=&quot;20&quot;></td>
</tr>
<tr>

<td><strong>Password:</strong></td>

<td>
<label>
<input name=&quot;Pass&quot; type=&quot;text&quot; value=&quot;<%=strPass%>&quot; size=&quot;20&quot;>
</label></td>
</tr>
<tr>
<td><strong>Password2:</strong></td>

<td>
<label>
<input name=&quot;pass2&quot; type=&quot;text&quot; value=&quot;<%=strPass2%>&quot; size=&quot;20&quot;>
</label></td>
</tr>
<tr>
<td><strong>Futebol:</strong></td>
<td>
<input type=&quot;checkbox&quot; value=&quot;ON&quot; <% if strFut = sim then Response.Write(&quot;checked&quot;) %>></td>
</tr>
</table>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;update.asp?Colect=<%=sColect%>&quot;>
<label>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Update&quot;>
</label>
</form>
<p>&nbsp;</p>
</body>
</html>

--------------
Update.asp
--------------

<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<%
dim conn, supdate, spass, spass2, scolect, sId

iId = Request(&quot;Id&quot;)
scolect = Request(&quot;Colect&quot;)
spass = Request(&quot;pass&quot;)
spass2 = Request(&quot;pass2&quot;)

response.write(iId)

set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.open &quot;dsn=direct&quot;
set sUpdate = conn.execute(&quot;Update member set Password='&quot; & spass & &quot;',Password2='&quot; & spass2 & &quot;' Where(Id like '&quot; & iId & &quot;')&quot;)

%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>


<div align=&quot;center&quot;>
<p><font size=&quot;5&quot;>You information has been Updated </font></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p></p>
</div>

</body>
</html>

Please see the code and help find the error.
 
Hi,

I thought you fixed this problem yesterday? What particular error message are you getting?

You update statement shouldn't be using 'like' to find the id value, it will be exact, and should be like this:

set sUpdate = conn.execute(&quot;Update member set Password='&quot; & spass & &quot;',Password2='&quot; & spass2 & &quot;' Where Id =&quot; & iId)

Does this fix it?
Nick (Web Developer)


nick@retrographics.co.uk
 
Even with all the help you gave me i couldn't solve the problem.

When i put the things like you said on your last example i get this message:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][Controlador Microsoft Access de ODBC] sintax error (missing operator) on the query expression 'Id ='.

/search/update.asp, line14

I've tried all the possible ways, and i can't solve the problem
 
Your form tags don't surround your input tags! The only thing that is getting mailed to the next screen is the submit field. You need to open the form above any input tags and close it right at the end. Only things within the form tag will get sent!
Nick (Web Developer)


nick@retrographics.co.uk
 
Thanks Nick, this is just so stupid, i just can seem to understand how i could make such a mistake, this is a really big beginners error.

Thank you again, for your pacience.

Herminio, Portugal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top