类型不匹配: tempaddtime

shuizhilang 2008-03-27 07:11:23
set rs=server.createobject("adodb.recordset")
sql="select NewsID,UpdateTime,smallclassid from news where NewsID=" & NewsID
rs.open sql,conn,1,3
smallclassidnw=rs("smallclassid")
tempaddtime=rs("UpdateTime") 'UpdateTime是时间类型
rs.close


set rs=server.createobject("adodb.recordset")
sql="select * from news where NewsID="&NewsID
rs.open sql,conn,3,3

rs("fpath")=cstr(year(tempaddtime)) &"-" & cstr(month(tempaddtime)) 'fpath是文本类型

rs.update

数据库是access,如果把tempaddtime用now()代的话,就不会出现类型不匹配: tempaddtime这样的错误,不知道是怎么一回事
...全文
58 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
shuizhilang 2008-03-28
  • 打赏
  • 举报
回复
真是奇怪,我加了一个这个tempaddtime1好了,真奇怪

set rs=server.createobject("adodb.recordset")
sql="select NewsID,UpdateTime,smallclassid from news where NewsID=" & NewsID
rs.open sql,conn,1,3
smallclassidnw=rs("smallclassid")
tempaddtime=rs("UpdateTime")
tempaddtime1=tempaddtime
response.write tempaddtime
rs.close

temptime =year(tempaddtime) & "年" & month(tempaddtime) & "月" & day(tempaddtime) & "日"
filename1=makefilename(tempaddtime)& ".asp"

set rs=server.createobject("adodb.recordset")
sql="select * from news where NewsID="&NewsID
rs.open sql,conn,3,3

rs("fpath")=cstr(year(tempaddtime1) &"-" & month(tempaddtime1))

rs.update

filename1 = makefilename(tempaddtime)&".asp"
folder = "..\"&cstr(year(tempaddtime1) &"-" & month(tempaddtime1))
'生成HTML页面
Set fso = Server.CreateObject("Scripting.FileSystemObject")
'如果文件夹不存在则新建
if not fso.Folderexists(Server.MapPath(folder)) then fso.CreateFolder(Server.MapPath(folder))
Set fout = fso.CreateTextFile(Server.MapPath(folder&"\"&filename1))
fout.WriteLine okfile
fout.close
set fout=nothing
set fso=nothing

谢谢大家...不过还是不知道怎么一回事



shuizhilang 2008-03-28
  • 打赏
  • 举报
回复
2008-1-23 18:01:00
shuizhilang 2008-03-28
  • 打赏
  • 举报
回复
是这种格式2008-3-18 20:47:41
  • 打赏
  • 举报
回复
tempaddtime=rs("UpdateTime") 'UpdateTime是时间类型
你这个字段里保存的是2008123180100这种格式???这个格式哪是时间格式哦
shuizhilang 2008-03-28
  • 打赏
  • 举报
回复
是这个2008-3-18 23:09:032008318230903
shuizhilang 2008-03-28
  • 打赏
  • 举报
回复
asp中如何定义时间变量
hookee 2008-03-28
  • 打赏
  • 举报
回复
从2008123180100看似乎是不能CDate的

tempaddtime=rs("UpdateTime")
response.write tempaddtime 看下显示什么?
shuizhilang 2008-03-28
  • 打赏
  • 举报
回复
我没有用dim 申明tempaddtime变量,asp自认是什么类型的变量,
shuizhilang 2008-03-28
  • 打赏
  • 举报
回复
显示:类型不匹配: '[string: "2008123180100"]'


我是直接把tempaddtime=CDate(rs("UpdateTime").value) '其中UpdateTime是日期时间类型
hookee 2008-03-28
  • 打赏
  • 举报
回复
在不行之前 response.write tempaddtime看下显示的是什么?
shuizhilang 2008-03-28
  • 打赏
  • 举报
回复
这是我的源码:
set rs=server.createobject("adodb.recordset")
sql="select NewsID,smallclassid from news where NewsID=" & NewsID
rs.open sql,conn,3,3
smallclassidnw=rs("smallclassid")
tempaddtime=CDate(rs("UpdateTime"))
rs.close

temptime =year(tempaddtime) & "年" & month(tempaddtime) & "月" & day(tempaddtime) & "日"
filename1=makefilename(tempaddtime)& ".asp"

set rs=server.createobject("adodb.recordset")
sql="select * from news where NewsID="&NewsID
rs.open sql,conn,3,3


rs("fpath")=cstr(year(tempaddtime)) &"-" & cstr(month(tempaddtime)) '这里不行
rs("fname")=filename1
rs("demoid")=request.QueryString("demoid")
rs.update


folder = "..\"&cstr(year(tempaddtime) &"-" & month(tempaddtime)) '这里不行
ymle1228 2008-03-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 chinmo 的回复:]
tempaddtime=rs("UpdateTime")
你这样后就变成字符串了
再使用时最好使用转换
[/Quote]

以前也有这个问题
ymle1228 2008-03-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 hookee 的回复:]
tempaddtime=CDate(rs("UpdateTime").Value)
[/Quote]

以前也有这个问题!
ymle1228 2008-03-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 hookee 的回复:]
tempaddtime=CDate(rs("UpdateTime").Value)
[/Quote]

以前也有这个问题!
hookee 2008-03-27
  • 打赏
  • 举报
回复
tempaddtime=CDate(rs("UpdateTime").Value)
  • 打赏
  • 举报
回复
tempaddtime=rs("UpdateTime")
你这样后就变成字符串了
再使用时最好使用转换
  • 打赏
  • 举报
回复
rs("fpath")=cstr(year(cdate(tempaddtime))) &"-" & cstr(month(cdate(tempaddtime)))

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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