我原来用access的时候,代码执行一切正常,可是将mdb倒入sql server2000后,在其他的asp中进行sql 操作就报错???

caoyuan1980 2003-08-19 11:32:00
我原来用access的时候,代码执行一切正常,可是将mdb倒入sql server2000后,在其他的asp中进行sql 操作就报错。
祥见http://expert.csdn.net/Expert/topic/2165/2165449.xml?temp=.4610407
如在main.asp中:
<!--#include file="conn.asp"-->
……
sql="select top "&maxrecordnum&" userid,sayto,saycontent,textcolor,userface,ispublic,puttime from chatinfo where puttime>#"&dateadd("s",(0-5*sessionout),now())&"# order by puttime desc"

rs.open sql,conn,0,1

在index.asp中却运行正常:
<!--#include file="conn.asp"-->
……
sql="select * from userinfo where userid='"&trim(keystr)&"'"
rs.open sql,conn,0,3

这是为什么呢?
...全文
23 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
caoyuan1980 2003-08-21
  • 打赏
  • 举报
回复
up
caoyuan1980 2003-08-20
  • 打赏
  • 举报
回复
up
caoyuan1980 2003-08-20
  • 打赏
  • 举报
回复
试过了,不行啊,puttime 是datatime类型的,不能加单引号
wyxl 2003-08-20
  • 打赏
  • 举报
回复
UP
dafu71 2003-08-20
  • 打赏
  • 举报
回复
sql="select top "&maxrecordnum&" userid,sayto,saycontent,textcolor,userface,ispublic,puttime from chatinfo where puttime>'"&dateadd("s",(0-5*sessionout),now())&"' order by puttime desc"

#改为 ' 试试
caoyuan1980 2003-08-19
  • 打赏
  • 举报
回复
我只要把:
sconn = "Provider=SQLOLEDB;Database=chatdb;Server=localhost;UID=sa;PWD=sa;"
set conn = Server.CreateObject("ADODB.connection")
conn.Open sconn

改回access为:
dbpath=server.mappath("chatdb/chatdb.mdb")
set conn=server.createobject("adodb.connection")
conn.open "PROVIDER=Microsoft.jet.OLEDB.4.0;data source="&dbpath
就没有问题了

34,589

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧