当用户提交结果时将日期和时间保存到访问文件中
当用户提交个人结果时,我试图将日期或时间保存到数据库文件中。 目前,我可以使用 UPDATE 函数保存除日期或时间之外的所有其他信息。我知道有一些名为 date() 和 now() 的函数用于日期操作。但我就是做不到。并且不用太担心 SQL 注入;这仅供我自己使用。
部分代码在这里:
id=request.QueryString("id")
name=request.Form("name")
sex=request.Form("sex")
age=request.Form("age")
logtime=date() // I am not sure if this is correct
sql="select * from table where id="&id
set rs=conn.execute(sql)
sql="update table set name='"+name+"', sex='"+sex+"', age='"+age+"', logtime='"+logtime+"' where id="&id // for the logtime='"+logtime+"', I think it is also not correct.
'response.Write sql
conn.execute(sql)
conn.close
set conn=nothing
I am trying to save date or time into a database file when the user submit the personal results.
Currently, I am able to save all other information using the UPDATE function except the date or time. I know there are functions called date() and now() for date manipulation. But I just cannot get it right. And don't worry too much about SQL injection; this is just for my own use.
Part of the code is here:
id=request.QueryString("id")
name=request.Form("name")
sex=request.Form("sex")
age=request.Form("age")
logtime=date() // I am not sure if this is correct
sql="select * from table where id="&id
set rs=conn.execute(sql)
sql="update table set name='"+name+"', sex='"+sex+"', age='"+age+"', logtime='"+logtime+"' where id="&id // for the logtime='"+logtime+"', I think it is also not correct.
'response.Write sql
conn.execute(sql)
conn.close
set conn=nothing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为在经典 ASP 中它是:
I think in Classic ASP it's:
正如您发布的另一个问题中提到的,您的解决方案存在 SQL 注入 的安全风险,并且您应该使用参数化 SQL 查询。此外,您的
conn.Execute(sql)
实际上应该是conn.Execute sql
或Call conn.Execute(sql)
。此外,通过使用参数化查询,日期处理变得更好,例如:As mention in the other question you posted, your solution has a security risk of SQL injection and that you ought to use parametized SQL queries. In addition, your
conn.Execute(sql)
should really beconn.Execute sql
orCall conn.Execute(sql)
. In addition, by using parametized queries, date handling becomes better, for instance:对于访问数据库,您必须遵循以下格式
#YYYY-MM-DD#
-- 某些版本将接受“YYYY-MM-DD”
快乐编码!
For access database you would have to follow below format
#YYYY-MM-DD#
-- some versions will accept 'YYYY-MM-DD'
Happy coding!!