|
| |
|
|
paulie
Posts: 558 Status: offline
|
Writing Timestamp to Access via ASP - 9/10/2003 12:25:18
Is there a way to add the Timestamp to my SQL statement when doing an Insert like so: mySQL= mySQL & "(name,email,company) " mySQL= mySQL & "VALUES ('" & Request.Form("name") & "','" mySQL= mySQL & Request.Form("email") & "'" mySQL= mySQL & ",'" & Request.Form("company") mySQL= mySQL & "','" & Request.Server("Timestamp") & "')" As a guess, I tried the request.server object and got an "object not supported" error. My DB is Access 2000.
|
|
|
|
rdouglass
Posts: 9272 From: Biddeford, ME USA Status: offline
|
RE: Writing Timestamp to Access via ASP - 9/10/2003 12:53:16
quote:
mySQL= mySQL & "','" & Request.Server("Timestamp") & "')" Try this: mySQL= mySQL & "',#'" & Now() & "#)"
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
rdouglass
Posts: 9272 From: Biddeford, ME USA Status: offline
|
RE: Writing Timestamp to Access via ASP - 9/10/2003 12:55:05
quote:
mySQL= mySQL & "(name,email,company) " OOPS...gotta' make sure you add your Access field to the fieldlist: mySQL= mySQL & "(name,email,company,timeFieldName) "
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
paulie
Posts: 558 Status: offline
|
RE: Writing Timestamp to Access via ASP - 9/10/2003 13:20:19
Thanks Roger, When I try mySQL= mySQL & "',#'" & Now() & "#)" I get "Extra ) in query expression '#'9/10/2003 12:09:53 PM#)'. So when I remove the extra right parens I get: Syntax error in INSERT INTO statement Here is the whole shebang in case you can spot any other ID ten T errors: Dim myConnString Dim myConnection Dim mySQL myConnString = Application("cadregister_ConnectionString") Set myConnection = Server.CreateObject("ADODB.Connection") myConnection.Open myConnString mySQL= "INSERT INTO Results " mySQL= mySQL & "(name,email,company,[Timestamp]) " mySQL= mySQL & "VALUES ('" & Request.Form("name") & "','" mySQL= mySQL & Request.Form("email") & "'" mySQL= mySQL & ",'" & Request.Form("company") mySQL= mySQL & "',(#'" & Now() & "#)" myConnection.Execute mySQL myConnection.Close Set myConnection = Nothing The SQL Syntax Gods must be hungry today...
|
|
|
|
rdouglass
Posts: 9272 From: Biddeford, ME USA Status: offline
|
RE: Writing Timestamp to Access via ASP - 9/10/2003 13:46:23
Do you actually have a field "Timestamp" and is it a Date/Time field? Also this line: mySQL= mySQL & "',(#'" & Now() & "#)" has an extra paren. Try: mySQL= mySQL & "',#'" & Now() & "#)"
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
paulie
Posts: 558 Status: offline
|
RE: Writing Timestamp to Access via ASP - 9/10/2003 13:52:31
quote:
Do you actually have a field "Timestamp" and is it a Date/Time field? Affirmative. And as "Timestamp" is a reserved word in Access and SQL, I have tried it with and without the square brackets. Still getting the obscure " Syntax error in INSERT INTO statement.", so I'll keep throwing variations at it until I find one it likes.
|
|
|
|
rdouglass
Posts: 9272 From: Biddeford, ME USA Status: offline
|
RE: Writing Timestamp to Access via ASP - 9/10/2003 14:19:15
quote:
Dim myConnString Dim myConnection Dim mySQL myConnString = Application("cadregister_ConnectionString") Set myConnection = Server.CreateObject("ADODB.Connection") myConnection.Open myConnString mySQL= "INSERT INTO Results " mySQL= mySQL & "(name,email,company,[Timestamp]) " mySQL= mySQL & "VALUES ('" & Request.Form("name") & "','" mySQL= mySQL & Request.Form("email") & "'" mySQL= mySQL & ",'" & Request.Form("company") mySQL= mySQL & "',(#'" & Now() & "#)" myConnection.Execute mySQL myConnection.Close Set myConnection = Nothing Try putting a response.write in there to see what it spits out: Dim myConnString Dim myConnection Dim mySQL myConnString = Application("cadregister_ConnectionString") Set myConnection = Server.CreateObject("ADODB.Connection") myConnection.Open myConnString mySQL= "INSERT INTO Results " mySQL= mySQL & "(name,email,company,[Timestamp]) " mySQL= mySQL & "VALUES ('" & Request.Form("name") & "','" mySQL= mySQL & Request.Form("email") & "'" mySQL= mySQL & ",'" & Request.Form("company") mySQL= mySQL & "',(#'" & Now() & "#)" response.write mySQL myConnection.Execute mySQL myConnection.Close Set myConnection = Nothing Then can you post back the results of the Response.write?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
paulie
Posts: 558 Status: offline
|
RE: Writing Timestamp to Access via ASP - 9/10/2003 14:24:07
Here is the error in full: INSERT INTO Results (name,email,company,Timestamp) VALUES ('My Name','myemail@address.com','My Company',#'9/10/2003 1:17:35 PM#) Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. /backupcad_library.asp, line 45
|
|
|
|
best
Posts: 2 Joined: 8/15/2004 Status: offline
|
RE: Writing Timestamp to Access via ASP - 8/15/2004 15:45:00
hi, i'm new to asp. i need some help here.i want to insert timestamp to my database(access) in my timestamp field(type is Date/Time) . i read all ya previous posts, and tried to slove it myself. well basically i was able to write out e sql statement , but was not able to insert into DB. kinda weird that i couldnt close e connection. pls look into my code. desperately need help. .ty in advance quote:
<% dim strName dim strRegnick dim strHdd dim strConn dim strRec Dim strUptime Dim strServe Dim mySQL Dim conn dim adoCon strName=Request.Form("nick") strRegnick=Request.Form("regnick") strHdd=Request.Form("hdd") strConn=Request.Form("conn") strRec=Request.Form("rec") strUptime=Request.Form("uptime") strServe=Request.Form("serve") Set adoCon = Server.CreateObject("ADODB.Connection") conn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("databases/xiso.mdb") adoCon.Open conn Set rs = SERVER.CreateObject("ADODB.Recordset") mySQL = "INSERT INTO reg (nick,regnick,hdd,conn,rec,uptime,serve,[Timestamp]) VALUES ( '"& strName &"' , '"& strRegnick &"' , '"& strHdd &"' , '"& strConn &"' , '"& strRec &"', '"& strUptime &"', '"& strServe &"')" mySQL= mySQL & "',('" & Now() & ")" 'conn.Execute mySQL 'conn.Close 'rs.Open mySQL, conn 'Set conn = Nothing response.write mySQL %>
|
|
|
|
Spooky
Posts: 26603 Joined: 11/11/1998 From: Middle Earth Status: offline
|
RE: Writing Timestamp to Access via ASP - 8/15/2004 16:04:01
Please start a new thread if this doesnt work. mySQL = "INSERT INTO reg (nick,regnick,hdd,conn,rec,uptime,serve,[Timestamp]) VALUES ( '"& strName &"' , '"& strRegnick &"' , '"& strHdd &"' , '"& strConn &"' , '"& strRec &"', '"& strUptime &"', '"& strServe &"', Now())"
_____________________________
If you arent part of the solution, then there is good money to be made prolonging the problem §þ k¥
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|