Click to See Complete Forum and Search --> : ASP, Access, Insert Into
PhilgB
05-01-2003, 08:38 AM
sql = "INSERT INTO tblCalendar (timeStart, timeEnd, title, desc, owner, public)"
sql = sql & "VALUES (#"& startDate &"#,#"& endDate &"#,'"& strTitle &"','"& strDesc &"',"& usrId &",'"& blnPublic &"')"
I'm getting a syntax error in this sql statement. Are any of those field names reserved? Or are there any other problems that anyone can see?
Thanks.
david2105
05-01-2003, 10:52 AM
The word "desc" is a reserved word in SQL. It is used as a parameter of Sort By to Sort descending rather than ascending. You'll have to change your table name.
david2105
05-01-2003, 10:53 AM
Sorry that should be field name rather than table name
Nicodemas
05-01-2003, 11:58 AM
Could he also put the braces around desc? [Desc]?
PhilgB
05-01-2003, 01:15 PM
Yeah I thought about the [] thing but still gave me an error. Changed 'desc' to 'details'. This is what I have now.
sql = "INSERT INTO tblCalendar (timeStart, timeEnd, title, details, owner, public)"
sql = sql & "VALUES (#"& startDate &"#,#"& endDate &"#,'"& strTitle &"','"& strDesc &"',"& usrId &","& blnPublic &")"
blnPublic is is True of False, should there be single quotes around it?
I also tried 1 and 0 for blnPublic, but got the same result.
How does Access handle Yes/No fields?
I thought however that it would return a db problem, not syntax...
Thanks.
PhilgB
05-02-2003, 01:23 AM
Yeah thats exactly what I have. Ive tried variables with the value true/false, the words "true"/"false" and 1/0...
Still getting error...
Nicodemas
05-02-2003, 01:29 AM
This is a snippet from one of my web pages. It works and I just use TRUE/FALSE, no quotes, as you can see.
<%
strDB = Server.MapPath("../_data/AFStatus.mdb")
strSQL = "UPDATE tblMain SET IsAdmin = FALSE"
ysnSuccess = adlExecuteSQL(strDB,strSQL,NULL)
response.redirect("../default.asp")
%>
PhilgB
05-02-2003, 06:06 AM
For future reference.... the name 'public' causes problems with sql. Changed it to isPublic and all is good!
Thank you everyone!