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!

Hello, can anyone please check whet

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello, can anyone please check whether the following code is correct? It seem to be that it is not working.


<%

if (Request.Form (&quot;submit&quot;) <> &quot;&quot;) Then

Dim adoCon, adoRec ' ADO connection object
Dim ConnString
Dim myNameID, myUserID, myPwd, myDept, myYr, myEmail, sql

myNameID = Request.Form (&quot;text1&quot;)
myUserID = Request.Form (&quot;text2&quot;)
myPwd = Request.Form (&quot;password1&quot;)
myDept = Request.Form (&quot;select1&quot;)
myYr = Request.Form (&quot;select10&quot;)
myEmail= Request.Form (&quot;text3&quot;)


Set adoCon = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set adoRec=server.CreateObject (&quot;ADODB.Recordset&quot;)
ConnString=&quot;driver={sql server};server=Mell; database=portal;DSN=localserver;PWD=;UID=sa;&quot;
adoCon.Open ConnString

adoRec.ActiveConnection = adoCon

sql= &quot; UPDATE info &quot; & _
&quot;SET NameID='&quot; & myNameID & &quot;', &quot; & _
&quot;UserID='&quot; & myUserID & &quot;', &quot; & _
&quot;password='&quot; & myPwd & &quot;', &quot; & _
&quot;yearinfo='&quot; & myYr & &quot;', &quot; & _
&quot;email='&quot; & myEmail & &quot;', &quot; & _
&quot;WHERE department='&quot; & myDept & &quot;'&quot;

adoCon.Execute (sql)

Response.Redirect (&quot;Continue&quot;)

else%>
<script>
window.alert(&quot;Records cannot be updated&quot;);
</script>
<%End if

adoCon.Close
Set adoCon = Nothing

%>


thank You!! :-V
 
Leave out the parenthesis in the execute command. As far as I know, you only need the parenthesis when you are assigning the result to something.

adoCon.Execute sql

It's hard to know when you didn't tell us what the problem is. Mise Le Meas,

Mighty :)
 
also, your Response.Redirect (&quot;Continue&quot;) needs to be a valid page to go to. if you're redirecting to a variable containing that page location, then you need to drop the &quot;&quot;'s around &quot;Continue&quot;.
 
Hello, whenever i click &quot;submit&quot;, it give me this result:
&quot;Records cannot be updated&quot;.
So can you check that is my looping correct?

<%

if (Request.Form (&quot;submit&quot;) <> &quot;&quot;) Then

Dim adoCon, adoRec ' ADO connection object
Dim ConnString
Dim myName, myUserID, myPwd, myDept, myYr, myEmail, SQL

myName = Request.Form (&quot;text1&quot;)
myUserID = Request.Form (&quot;text2&quot;)
myPwd = Request.Form (&quot;password1&quot;)
myDept = Request.Form (&quot;select1&quot;)
myYr = Request.Form (&quot;select10&quot;)
myEmail= Request.Form (&quot;text3&quot;)


Set adoCon = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set adoRec=server.CreateObject (&quot;ADODB.Recordset&quot;)
ConnString=&quot;driver={sql server};server=CON7; database=user;DSN=localserver;PWD=sa;UID=sa;&quot;
adoCon.Open ConnString

adoRec.ActiveConnection = adoCon

SQL= &quot; UPDATE info &quot; & _
&quot;SET NameID='&quot; & myName & &quot;', &quot; & _
&quot;UserID='&quot; & myUserID & &quot;', &quot; & _
&quot;password='&quot; & myPwd & &quot;', &quot; & _
&quot;yearinfo='&quot; & myYr & &quot;', &quot; & _
&quot;email='&quot; & myEmail & &quot;' &quot; & _
&quot;WHERE course='&quot; & myDept & &quot;'&quot;

adoCon.Execute SQL

adoCon.Close
Set adoCon = Nothing

Response.Redirect (&quot;
else%>
<script>
window.alert(&quot;Records cannot be updated&quot;);
</script>
<%End if

%>

Thank You :-V
 
Did you name your submit button? Does it look like the piece of code below?

<input type=&quot;submit&quot; name=&quot;something&quot; value=&quot;Next Step&quot;>


In this case you'll be able to the value of &quot;Next Step&quot;, using Request.Form(&quot;something&quot;).

And you could then use your If ... Then
 
actually, since it checks:

if (Request.Form (&quot;submit&quot;) <> &quot;&quot;) Then

Then the submit button needs to be named &quot;submit&quot;:

<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Next Step&quot; action=&quot;nextStep.asp&quot;>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top