Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 4th, 2004, 07:01 PM
Authorized User
 
Join Date: Feb 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default error in code

I have the following error in my ASP if and else stmt,and I have tried diff things on it and it's not working.( the code looks fine to me)
Here's the error:
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'
Here's the code:
<% Response.Buffer = true %>

<html>
<head>
<Title>Passoword change website</title>
</head>
<body>
<h2>Password change response<h2>
<%

'Declare variable needed
Dim strSql
Dim adCmdText

adCmdText = 1

'Retrieve the values
varStudentID = Request.Form("StudentId")
varPassword = Request.Form("Password")
varNewpassword = Request.Form("NewPassword")


'start building sql statement
strSql = "Update Try Set"
strSql = strSql & " Password ='" & varNewpassword & "'"
strSql = strSql & " WHERE StudentID =" & varStudentID
strSql = strSql & " AND Password='" & varPassword & "'"

'Create and Open connection to database
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.OPen "DSN=new1"

if objconn.eof then
Response.Write "Incorrect username or password"

'Create command object
Set objCmd = Server.CreateObject("ADODB.Command")

'Set Command Properties
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = strSql
objCmd.CommandType = adCmdText

'Execute Command
 set objRS = objCmd.Execute


'Check if the user entered a valid username and password.

If objRS.EOF or objRS.BOF Then
        Response.Write "Incorrect Username or password please try again"
    Response.Clear
    Response.Redirect "New112.asp"
Else
    Response.Write "You have successfuly changed your password"
End If

'Response.Write " Your passwords has been changed."
'Response.write " The number of record that has changed is: " & _
' intnumofrecord & " records<BR><BR>"

Set objRS = Nothing
objRS.close
Set objCmd = Nothing
objConn.Close
Set objConn = Nothing

%>

</body>
</html>




 
Old March 4th, 2004, 11:09 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your problem is here:

<%
if objconn.eof then
Response.Write "Incorrect username or password"

'should have closing "End If"
'...
%>

 
Old March 5th, 2004, 11:29 AM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hamed8esi Send a message via Yahoo to hamed8esi
Default

ur first if doesn't have any end if, you should close ur if as :
If <condition> then
<statement>
end if

ur error ->
if objconn.eof then
....
end if ' you shoul insert this code at the end of the page






Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Code NadAf BOOK: Ivor Horton's Beginning Visual C++ 2005 0 February 18th, 2008 11:16 PM
Code error reverand Excel VBA 1 November 15th, 2006 02:08 AM
Code error??? emyr BOOK: Beginning Java 2 1 October 31st, 2006 05:47 PM
Code error!?!? Brian Campbell BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 3 November 26th, 2004 07:47 PM
Error displayed with error trap code stoneman Access 4 February 28th, 2004 02:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.