ASP page syntax error

Discussion in 'Classic ASP' started by jung1975, Jun 24, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. "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>


    <%

    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
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    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") & "')"


    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>


    <%

    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">
     
  3. 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
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page