Right, I'm designing a webadmin interface for an online entertainment guide. I'm currently having problems with a page which allows the user to choose which movies (using checkboxes) they want to associate with a certain cinema on a certain date. So far so good.
However, I've added the capability to enter a short string into a text area to specify showing times and other conditions. This is where my SQL breaks down.
The page which accepts entry from this form does so in a loop:
'Cycle through the selected checkboxes and generate SQL command
For intCount = 1 to Request.Form("Movie".Count
'Increment DiaryID to allow multiple entries with same date and cinema ID
intDiaryID = intDiaryID + 1
'Get MovieID from current Checkbox
intMovieID = Request.Form("Movie" (intCount)
'Get the text from the Info Text box for current checked entry
strInfo = Request.Form(intDiaryID)
'SQL Command generation and execution
objComm.CommandText = "INSERT INTO Diary (DiaryID, DateID, CinemaID, MovieID, Info) VALUES" & _
"( " & intDiaryID & ", " & intDateID & ", " & intCinemaID & ", " & intMovieID & ", " & strInfo & ""
objComm.Execute
objComm.Close
Set objComm = Nothing
Next
I'm getting the following error:
Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement
The line causing the error is obviously the SQL, and the only change is that I've tagged on the text string field name and variable it is held in when processed from the form, (Info and strInfo respectively_
I've also checked there's no problem with required fields / disallowing empty zero length.
Any ideas?
However, I've added the capability to enter a short string into a text area to specify showing times and other conditions. This is where my SQL breaks down.
The page which accepts entry from this form does so in a loop:
'Cycle through the selected checkboxes and generate SQL command
For intCount = 1 to Request.Form("Movie".Count
'Increment DiaryID to allow multiple entries with same date and cinema ID
intDiaryID = intDiaryID + 1
'Get MovieID from current Checkbox
intMovieID = Request.Form("Movie" (intCount)
'Get the text from the Info Text box for current checked entry
strInfo = Request.Form(intDiaryID)
'SQL Command generation and execution
objComm.CommandText = "INSERT INTO Diary (DiaryID, DateID, CinemaID, MovieID, Info) VALUES" & _
"( " & intDiaryID & ", " & intDateID & ", " & intCinemaID & ", " & intMovieID & ", " & strInfo & ""
objComm.Execute
objComm.Close
Set objComm = Nothing
Next
I'm getting the following error:
Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement
The line causing the error is obviously the SQL, and the only change is that I've tagged on the text string field name and variable it is held in when processed from the form, (Info and strInfo respectively_
I've also checked there's no problem with required fields / disallowing empty zero length.
Any ideas?