永发信息网

急:关于ASP从字符串转换为 datetime 时发生语法错误

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