INSERT INTO syntax error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following code generates a syntax error. I have tracked it down to "Date". So there is a problem when I pull the Date from the txtDate textbox and try to insert it into the database. I'm using a Long date, but also tried formatting txtDate as a short date and get the same error. What am I doing wrong

INSERT INTO Session (ClassID, SessionNum, Date, FID, FSNum, StartTime, EndTime, Topic) Values (ddlClass, txtSessionNum, txtDate, ddlFaculty, txtFSNum, txtStartTime, txtEndTime, txtTopic)

Thanks

Kyle
 
Date is a reserved word and should be enclosed in [] when
refering to a user column e.g.
INSERT INTO Session (ClassID, SessionNum, [Date], FID,
FSNum, StartTime, EndTime, Topic) Values (ddlClass,
txtSessionNum, txtDate, ddlFaculty, txtFSNum, txtStartTime,
txtEndTime, txtTopic);

Better still, rename the column.

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
The following code generates a syntax error. I have
tracked it down to "Date". So there is a problem when I
pull the Date from the txtDate textbox and try to insert it
into the database. I'm using a Long date, but also tried
formatting txtDate as a short date and get the same error.
What am I doing wrong?
INSERT INTO Session (ClassID, SessionNum, Date, FID,
FSNum, StartTime, EndTime, Topic) Values (ddlClass,
txtSessionNum, txtDate, ddlFaculty, txtFSNum, txtStartTime,
txtEndTime, txtTopic);
 
Back
Top