SQL 插入日期/时间和JavaScript 中获取的值
我正在尝试将当前日期/时间和重定向到此错误页面的值插入到访问数据库中。到目前为止,唯一的问题来自当我将重定向值添加到插入语句中时。这是我的代码。
errnum = Request.QueryString("errnum")
prevPageTitle = request.querystring("pagetitle")
Function AccessDateTime (dateandtime)
Dim myDay
Dim myMonth
Dim myYear
myDay = Day(dateandtime)
If Len(myDay)=1 Then myDay="0" & myDay
myMonth = Month(dateandtime)
If Len(myMonth)=1 Then myMonth="0" & myMonth
myYear = Year(dateandtime)
AccessDateTime = myYear & "-" & myMonth & "-" & myDay & " " & Time()
End Function
Dim connection
Dim SQL, sConnString
SQL="INSERT INTO ErrorTable (ErrorTime, ErrorPage) VALUES (#" & AccessDateTime(NOW()) & "#, #" & prevPageTitle & "#)"
//////This is where the issue is, ErrorPage column isn't updated with prevPageTitle acquired information.
(Error Type:
Microsoft JET Database Engine (0x80040E07)
Syntax error in date in query expression '#Pre-ErrorPage.asp#'.//////
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("ErrorTimeLog.mdb")
Set connection = Server.CreateObject("ADODB.Connection")
connection.Open(sConnString)
connection.execute(SQL)
Connection.Close
Set Connection = Nothing
I am trying to insert current date/time and a value that was redirected to this errorpage into an access database. So far the only issue is coming from when i add the redirected value into the insert statement. Here is my code.
errnum = Request.QueryString("errnum")
prevPageTitle = request.querystring("pagetitle")
Function AccessDateTime (dateandtime)
Dim myDay
Dim myMonth
Dim myYear
myDay = Day(dateandtime)
If Len(myDay)=1 Then myDay="0" & myDay
myMonth = Month(dateandtime)
If Len(myMonth)=1 Then myMonth="0" & myMonth
myYear = Year(dateandtime)
AccessDateTime = myYear & "-" & myMonth & "-" & myDay & " " & Time()
End Function
Dim connection
Dim SQL, sConnString
SQL="INSERT INTO ErrorTable (ErrorTime, ErrorPage) VALUES (#" & AccessDateTime(NOW()) & "#, #" & prevPageTitle & "#)"
//////This is where the issue is, ErrorPage column isn't updated with prevPageTitle acquired information.
(Error Type:
Microsoft JET Database Engine (0x80040E07)
Syntax error in date in query expression '#Pre-ErrorPage.asp#'.//////
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("ErrorTimeLog.mdb")
Set connection = Server.CreateObject("ADODB.Connection")
connection.Open(sConnString)
connection.execute(SQL)
Connection.Close
Set Connection = Nothing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以防万一有人需要类似问题的答案。问题出在我的 SQL 语句的语法中。
所获取的变量需要单引号。
Just in case anyone needs an answer to a similar question. The issue was in the syntax of my SQL statement.
Single quotes were needed around the acquired variables.