错误提示:从字符串转换为 datetime 时发生语法错误
sql="SELECt sum(1),sum(isnull(zonger,0)),sum(CASE WHEN zhuangtai<4 THEN 0 ELSE 1 END) FROM shop_action WHERe (datediff(d,fhsj,'"&day2&"')>=0) AND (datediff(d,'"&day1&"',fhsj)>=0)"
if rs.state=1 then rs.close
rs.open sql,conn,1,1 ‘提示此行出错!!!
急:关于ASP从字符串转换为 datetime 时发生语法错误
答案:2 悬赏:30 手机版
解决时间 2021-01-28 16:54
- 提问者网友:遁入空寂
- 2021-01-27 16:31
最佳答案
- 五星知识达人网友:忘川信使
- 2021-01-27 17:39
你把SQL语句输出一下,看看有没有语法错误
全部回答
- 1楼网友:佘樂
- 2021-01-27 18:40
microsoft ole db provider for sql server 错误 '80040e07' 从字符串转换为 datetime 时发生语法错误。 /manage/actionadd.asp,行36 <% option explicit if session("strauthlevel")<>"admin" then response.redirect("./index.asp?message=您没有管理权限!") end if %> <!-- #include file="../include/pmsysconst.inc" --> <!-- #include file="../include/pmsysutil.inc" --> <% dim iaction dim oconn, ors dim strsql iaction = request.form("action") dim strtitle, strcontent, strauthor, tmpublish, itype select case(iaction) case(101) strtitle = request.form("title") strcontent = request.form("content") strauthor = request.form("author") tmpublish = now() strcontent = replace(strcontent," ",vbcrlf) strcontent = replace(strcontent,"'","’") strcontent = replace(strcontent," "," ") set oconn = fngetadoconn() strsql = "insert into tblnews (strtitle, strauthor, strcontent, tmpublish) values ('" & strtitle & "', '" & strauthor & "', '" & strcontent & "', '" & tmpublish & "')" set ors = oconn.execute(strsql) <第36行> set ors = nothing set oconn = nothing response.redirect("./listnews.asp") %> <% <% '// '// 目的: 将日期型变量转成: yyyy-mm-dd 形式的字符串 '// 输入: 日期型变量 '// 输出: yyyy-mm-dd 形式的字符串 '// function fnformatdate(pdt) '// as string dim str str = vbnullstring if (year(pdt) < 1000) then str = str & "0" & year(pdt) & "-" else str = str & year(pdt) & "-" end if if (month(pdt) < 10) then str = str & "0" & month(pdt) & "-" else str = str & month(pdt) & "-" end if if (day(pdt)) then str = str & "0" & day(pdt) else str = str & day(pdt) end if fnformatdate = str end function %> 问题补充:我按你说的做了 strsql = "insert into tblnews (strtitle, strauthor, strcontent, tmpublish) values ('" & strtitle & "', '" & strauthor & "', '" & strcontent & "', '" & tmpublish & "')" 那最后的 '" & tmpublish & "')" 换成 " & tmpublish & ")" 就好了 但又出现下面的问题 microsoft ole db provider for sql server 错误 '80040e14' 第 1 行: '下午' 附近有语法错误。 /manage/actionadd.asp,行36
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯