September 1st, 2012, 11:13 AM
Join Date: Aug 2012
Time spent in forums: 58 m 37 sec
Reputation Power: 0
[ASP SQL] INSERT INTO + SELECT + Variables Syntax Error
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?
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.