Sql syntax in vb

beckyr

Registered User.
Local time
Today, 16:09
Joined
Jan 29, 2008
Messages
35
Can anyone tell me where my syntax error is - i thought that if something is hardcoded like TR0034 it doesnt need any quotation marks?

strsql = "Insert into tblWorking ( STU_ID, STU_SURNAME, STU_COURSE_CODE, STU_STANDING )"
strsql = strsql & "Select tblIncoming.STU_ID, tblIncoming.STU_SURNAME, tblIncoming.STU_COURSE_CODE, tblIncoming.STU_STANDING"
strsql = strsql & "From [tblIncoming]"
strsql = strsql & "Where [tblIncoming].STU_COURSE_CODE = TR0034 "

db.Execute (strsql)
 
Since it's a text value it still needs single quotes:

strsql = strsql & "Where [tblIncoming].STU_COURSE_CODE = 'TR0034'"

Also watch out for spaces between lines, as you're going to have statements running into each other (like "STU_STANDINGFrom").
 
Numeric values do not need to be placed in quotes but a String must always be in quotes. Place single quotes around the value.

strsql = strsql & "Where [tblIncoming].STU_COURSE_CODE = 'TR0034' "

pbaldy beat me to the punch :) Getting slow in my old age.
 

Users who are viewing this thread

Back
Top Bottom