0

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

1 Answer 1

1

Just in case anyone needs an answer to a similar question. The issue was in the syntax of my SQL statement.

SQL="INSERT INTO ErrorTable (ErrorTime,ErrorPage,ErrorNumber) VALUES (#" & AccessDateTime(NOW()) & "#, '" & prevPageTitle & "', '" & errnum & "')"

Single quotes were needed around the acquired variables.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.