PDA

View Full Version : ASP page syntax error


jung1975
06-24-2003, 12:27 AM
"In this page, the new visitor enters his firstname,lastname, a username and a password and hits Submit to get login details. If a visitor has already has login details and wants to change the password, they simply enter again all the details in this page and enter the new password and hit submit. Once submitted, the process is carried out in Register.asp which inserts his/her details in the database. The following is the code for the register.asp page"


<%@ Language=VBScript %>
<HTML><HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
[b]

<%

Dim sSQL,conn,rs
Set conn = Server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")

'DSN less connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.ConnectionString = "Data Source=" & Server.MapPath("login.mdb")
conn.open


strsql = "Select firstname,lastname from login"
set rs = conn.Execute (strsql)

if (rs.BOF)and (rs.EOF) then

sSQL = "Insert into admin (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"&
Request("userid") & "', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText

else

SQL = "Delete * from login where username= '" & Request.Form("userid") & "'"
conn.execute(SQL)
end if

sSQL = "Insert into login (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"&
Request("userid") & "', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText

'close the recordset
rs.close
set rs = nothing

'close the connection
conn.close
set conn = nothing

%>

<h2>Your login details have been saved to the database<h2>
<A HREF="login.asp">[Click here to go to login page]</A>
</BODY>
</HTML>

However, I am keep getting error message says:

Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/Register.asp, line 38


Any help would appreciated it
Jung

bruce
06-24-2003, 03:12 AM
Try dump out the sSQL string, it'll be much easier to debug

just insert this

response.write (sSQL)
response.end

after this statement

sSQL = "Insert into admin (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"&
Request("userid") & "', '" & Request("password") & "')"


[b]quote:Originally posted by jung1975

"In this page, the new visitor enters his firstname,lastname, a username and a password and hits Submit to get login details. If a visitor has already has login details and wants to change the password, they simply enter again all the details in this page and enter the new password and hit submit. Once submitted, the process is carried out in Register.asp which inserts his/her details in the database. The following is the code for the register.asp page"


<%@ Language=VBScript %>
<HTML><HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
[b]

<%

Dim sSQL,conn,rs
Set conn = Server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")

'DSN less connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.ConnectionString = "Data Source=" & Server.MapPath("login.mdb")
conn.open


strsql = "Select firstname,lastname from login"
set rs = conn.Execute (strsql)

if (rs.BOF)and (rs.EOF) then

sSQL = "Insert into admin (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"&
Request("userid") & "', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText

else

SQL = "Delete * from login where username= '" & Request.Form("userid") & "'"
conn.execute(SQL)
end if

sSQL = "Insert into login (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"&
Request("userid") & "', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText

'close the recordset
rs.close
set rs = nothing

'close the connection
conn.close
set conn = nothing

%>

<h2>Your login details have been saved to the database<h2>
<A HREF="login.asp">[Click here to go to login page]</A>
</BODY>
</HTML>

However, I am keep getting error message says:

Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/Register.asp, line 38


Any help would appreciated it
Jung

</blockquote id="quote"></font id="quote">

jung1975
06-24-2003, 09:04 AM
Now, the syntax error on login.asp page is gone.the register.asp page shows:
Insert into login(Firstname,lastname,username,password) Values('JUNG', 'john', 'jung', '####')

However, the records are still not inserted into a login table in Access DB.

What would be the problem?.

Any help would appreciated it

Thanks
Jung