Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Syntax error in INSERT INTO statement.....AARRRGGGHHHH

    Ok people,

    Would really appreciate some help on what seems a pretty straight forward issue. I need to insert a number of values in to a table ( something that is being done on numerous occasions within the website without any issues ). However, when it comes to this particular posting page I get the following error message :

    =======================================================
    INSERT INTO tblUsers (FullName, Email_Address, Username, Password) Select 'Test_name'as fullname, 'Test@test.com' as email_address, 'Test_username' as username, 'test_password' as password

    Microsoft JET Database Engine error '80040e14'

    Syntax error in INSERT INTO statement.

    /pencoedaafc/mailing_List_Submit.asp, line 123
    =======================================================

    I have displayed the select statement on the to the screen ( see top 3 lines ) and then get a Syntax error...

    If I copy the line of code as it is and put it in to an Access query ( which is the back end DB ) then it inserts with no issues...

    Any help on this one greatly appreciated...

    The full code for this section is below...

    =============================================
    set conn=server.createobject("ADODB.Connection")
    set strSQL=server.createobject("ADODB.Recordset")
    strMDBpath = Server.MapPath("pencoedaafc.mdb")

    conn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" + strMDBPath

    DIM rs_Current_Username
    Set rs_Current_Username = Server.CreateObject("ADODB.Recordset")
    strSQL = "Select Username From tblUsers WHERE Username = '" & strUsername & "'"

    'Query the database
    rs_Current_Username.Open strSQL, conn

    If rs_Current_Username.BOF and rs_Current_Username.EOF THEN

    Set rs_Register_User = Server.CreateObject("ADODB.Recordset")
    strSQL = "INSERT INTO tblUsers (FullName, Email_Address, Username, Password) Select '" & strName & "'as fullname, '" & strEmail & "' as email_address, '" & strUsername & "' as username, '" & strpassword & "' as password"

    Response.Write strSQL
    rs_Register_User.Open strSQL, conn
    Set rs_Register_User = Nothing

  • #2
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry people,

    I was just being a numpty...Dont know why it didn't occur to me earlier but just popped in to my head. The reason it was failing was because I was using reserved words in the select statement...

    Thought it was something obvious...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •