SQL语句怎么操作日期类型字段的数据?

DCD 2005-06-15 09:46:49
ACCESS数据库
datetime为“日期/时间”类型字段
SQL语句为:update news set datetime=#2005-6-14 14:57:39# where id =1
这样报错,插入日期也出错,我只能在ACCESS里面定义这个字段的默认值为“now()”了,但现在涉及到修改这个字段的操作,怎么弄都报错:(
...全文
196 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
DCD 2005-06-15
  • 打赏
  • 举报
回复
-_-b
果然是关键字
up1002 2005-06-15
  • 打赏
  • 举报
回复
对Access不熟悉。看起来没错,不知道datetime是不是access的内置关键字。

update news set [datetime]=#2005-6-14 14:57:39# where id =1 试试看
DCD 2005-06-15
  • 打赏
  • 举报
回复
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] UPDATE 语句的语法错误。
/mjw/mjw_admin/news_up.asp, 第 14 行



源代码:
<%@ LANGUAGE="VBSCRIPT"%>
<!--#include file="inc_top.asp"-->
<!--#include file="inc_news.asp"-->
<%
'sql = "select top 1 id from news order by id desc"

'set a = dbcon.Execute(sql)

'Response.write(a("id"))
sql = "update news set datetime='#"&now()&"#' where id="&request.QueryString("id")
Response.write(sql)


dbcon.Execute(sql)
response.Write("<meta http-equiv=""refresh"" content=""0;URL=news_manage.asp""><script language=""javascript"" type=""text/javascript"">alert(""新闻提升成功!"")</script>")

%>


你说的这个方法我早就试过了,不行
itzhiren 2005-06-15
  • 打赏
  • 举报
回复
update news set datetime='#2005-6-14 14:57:39#' where id =1

28,406

社区成员

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

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