INSERT INTO syntax error

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
 
G

Gerald Stanley

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top