PageAdmin网站内容管理系统(CMS)交流论坛

注册

 

QQ登录

只需一步,快速开始

发新话题 回复该主题

转换到MSSQL后出现的错误 [复制链接]

1#
用access数据库时,在自定义文件模型中,创建了一个网站统计模型,代码是:
[code]<html>
<head>
<style type="text/css">
div{font:12px/1.7em Verdana,Tahoma,Helvetica,Arial,sans-serif;}
div .hs{colorff0000}
</style>
</head>
<body bgColor="transparent">
<div>
○- 今日文章:<span class="hs"><%=Get_Data("co","select count(id) as co from article where datediff('d',thedate,Now())=0")%></span><br>
○- 文章总数:<span class="hs"><%=Get_Data("co","select count(id) as co from article")%></span><br>
○- 昨日访问:<span class="hs"><%=Get_Data("co","select count(id) as co  from pa_count where datediff('d',thedate,Now())=1")%></span><br>
○- 今日访问:<span class="hs"><%=Get_Data("co","select count(id) as co  from pa_count where datediff('d',thedate,Now())=0")%></span><br>
○- 上月访问:<span class="hs"><%=Get_Data("co","select count(id) as co  from pa_count where datediff('m',thedate,Now())=1")%></span><br>
○- 本月访问:<span class="hs"><%=Get_Data("co","select count(id) as co  from pa_count where datediff('m',thedate,Now())=0")%></span><br>
○- 访问总数:<span class="hs"><%=Get_Data("co","select count(id) as co  from pa_count")%></span>
</div>
</body>
</html>[/code]

制作好后在前台的模块中用html应用(自定义模块,加入HTML代码:<iframe width="200" scrolling="no" height="186" frameborder="0" allowtransparency="true" style="background-color:transparent;" src="/e/zdymodel/article/custom/94.aspx">
</iframe>)
这样做出来的网站统计,在页面显示正常,图片是这样的:



但使用actosql 工具把access 数据库直接转换到了MSSQL ,转换成功,修改web.config 参数启,启用了   MSSQL,问题就出现了,网站统计这个页面不显示了,出现了错误提示,如下图:



[color=Red]错误提示为:

“/”应用程序中的服务器错误。

'now' 不是可以识别的 内置函数名称。

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟[/color]

请求帮助
分享 转发
TOP
2#

用了 MSSQL 后,这个access 中now()函数代码得怎么改才能在mssql应用正常呢?

希望懂的,会的,帮助解决一下,
TOP
3#

试了,把代码中的now() 替换成getdate() 也不行,提示:为 datediff 指定的参数 1 无效
TOP
4#

这个函数还真是没弄明白,不会转换,怎么改写代码才能正常显示呢?
TOP
5#

搞定了,只需要更改为mssql 能正确识别的函数写法就行了

代码如下:

<div>
○- 今日文章:<span class="hs"><%=Get_Data("co","select count(id) as co from article where datediff(day,thedate,getdate())=0")%></span><br>
○- 文章总数:<span class="hs"><%=Get_Data("co","select count(id) as co from article")%></span><br>
○- 昨日访问:<span class="hs"><%=Get_Data("co","select count(id) as co  from pa_count where datediff(day,thedate,getdate())=1")%></span><br>
○- 今日访问:<span class="hs"><%=Get_Data("co","select count(id) as co  from pa_count where datediff(day,thedate,getdate())=0")%></span><br>
○- 上月访问:<span class="hs"><%=Get_Data("co","select count(id) as co  from pa_count where datediff(month,thedate,getdate())=1")%></span><br>
○- 本月访问:<span class="hs"><%=Get_Data("co","select count(id) as co  from pa_count where datediff(month,thedate,getdate())=0")%></span><br>
○- 访问总数:<span class="hs"><%=Get_Data("co","select count(id) as co  from pa_count")%></span>
</div>
TOP
发新话题 回复该主题