ASP 网页的插入记录(日期型)字段问题 再问!

来源:百度知道 编辑:UC知道 时间:2024/06/29 23:21:47
Time=date()
write="insert into lydata (time) values ("&Time&")"
conn.execute write

总是出错,高手帮个忙哈!

ASP向SQL传递DATETIME变量, 直接按照字符串处理即可

tm = date()
sql = "insert into lydata ([time]) values ('"& tm &"')"
conn.execute sql

如果是当前时间, 直接使用 SQL 函数 NOW() (ACCESS) 或者 GETDATE() (MSSQL)
sql = "insert into lydata ([time]) values (NOW())"

PS: 用太多的疑似关键字了..

:)

时间变量要在”##”中引用
Time=date()
write="insert into lydata (time) values (#"&Time&"#)"
conn.execute write

SQL查询允许直接调用函数你也可以写成这样:
write="insert into lydata (time) values (date())"
conn.execute write

Time=date()
write="insert into lydata (time) values ('"&Time&"')"
conn.execute write