#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0

    Question [ASP SQL] INSERT INTO + SELECT + Variables Syntax Error


    Hello,

    So I'm working in ASP Classic and I'm trying to write an SQL statement to insert into a table. The thing is, I want to use a select from AND I want to include some variables too.

    I know this can be done, but no matter what I try I can't make it work. Could someone take a look at my sql statement and see what's wrong with it?

    Code:
    sqlstr = "INSERT INTO [Scores] (STUID, SKName, HUnit, SHom, WHom, WHomSc)" &_ 
    "SELECT " & CInt(std) & ",Students.SKName," & wk & ",'" & spch & "','" &_ 
    wrch & "'," & wrsc & " FROM [Students] WHERE Students.UnID = " & CInt(std) & ")"
    I've already confirmed that all of the table and field names are spelled correctly, and that all of the variables are populated. The error I'm currently getting is:

    Microsoft JET Database Engine error '80040e14'

    Syntax error in INSERT INTO statement.

    /avalonhomework/addhw.asp, line 218
    Line 218 is my execute statement using the above sql string.

    Thanks,

    Tam.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    Paris Uppland
    Posts
    2,382
    Rep Power
    391
    The last right parenthesis should not be there.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0

    Red face D'Oh




    That was embarrassingly simple... thank you.

IMN logo majestic logo threadwatch logo seochat tools logo