Ask a Question related to ASP Database, Design and Development.
-
Jeremy #1
Trouble sending New Date() info to Access via asp
I'm having difficulty posting a timestamp to access from client-side
javascript using New Date().
The result gives a syntax error on my INSERT INTO command on the ASP.
If I take the Date Data out, all other data gets through just fine.
Here's my code:
JAVASCRIPT
document.repForm.Timestamp.value = ( new Date());
HTML
<input type="hidden"name="Timestamp">
....It works up to here at the submit, where it goes to the asp...
VBSCRIPT
Timestamp = Request.form("Timestamp")
set responseDB = server.createobject("ADODB.Connection")
responseDB.open "driver={Microsoft Access Driver
(*.mdb)};DBQ=C:\Inetpub\wwwroot\report\Application 04.mdb;UID=Admin"
sqlText = "INSERT INTO Results (Timestamp)"
sqlText = sqlText & " VALUES("
sqlText = sqlText & "'" & Timestamp & "'"
sqlText = sqlText & ")"
Response.Write sqlText
set ReturnSet = responseDB.Execute(sqlText)
Any help would be appreciated! Please email me...
Thanks,
Jeremy
Jeremy Guest
-
Sending a javascript function with collected info
Maybe this is the forum for this question... What I have is a flash module where people go through and click options to have something customized... -
Sending contact form info from Flash to ASP.net forwebmail sending
Hello, I am trying to complete a web contact form within a Flash movie. The form has already been designed. Now I am trying to send the form... -
Sending form info to mysql
Could anyone advise me of a suitable tutorial to send information, via a form, to mysqldatase. Ideally, im looking for a tut that also encompasses... -
Sending form info to original window
I have a popup window with a form: The popup window is opened like this: <SCRIPT LANGUAGE=javascript> window.open('primos.html', 'primos',... -
Windows XP sending hardware update info without my knowledge
Well the first one may be caused by having automatic updates on. You (re) installed a piece of hardware which in turn requires a driver and possibly... -
Hannibal #2
Re: Trouble sending New Date() info to Access via asp
Why not just send the date from server side using "now()" ???
even if you want the date to refelect the time the userloaded the page you
can stil do this;
document.repForm.Timestamp.value = "<%=now()%>";
then of course you could always just set a default value for that field in
access to "getDate()"
Or maybe i don't understand the problem?
"Jeremy" <jeremy_zifchock@yahoo.com> wrote in message
news:f9d85033.0310092342.223af080@posting.google.c om...> I'm having difficulty posting a timestamp to access from client-side
> javascript using New Date().
>
> The result gives a syntax error on my INSERT INTO command on the ASP.
> If I take the Date Data out, all other data gets through just fine.
>
> Here's my code:
> JAVASCRIPT
> document.repForm.Timestamp.value = ( new Date());
> HTML
> <input type="hidden"name="Timestamp">
>
> ...It works up to here at the submit, where it goes to the asp...
>
> VBSCRIPT
> Timestamp = Request.form("Timestamp")
>
> set responseDB = server.createobject("ADODB.Connection")
> responseDB.open "driver={Microsoft Access Driver
> (*.mdb)};DBQ=C:\Inetpub\wwwroot\report\Application 04.mdb;UID=Admin"
>
> sqlText = "INSERT INTO Results (Timestamp)"
> sqlText = sqlText & " VALUES("
> sqlText = sqlText & "'" & Timestamp & "'"
> sqlText = sqlText & ")"
>
> Response.Write sqlText
>
> set ReturnSet = responseDB.Execute(sqlText)
>
> Any help would be appreciated! Please email me...
>
> Thanks,
>
>
> Jeremy
Hannibal Guest
-
Bob Barrows #3
Re: Trouble sending New Date() info to Access via asp
Your question really is not about client-side coding. I was all set to
advise you to go to another newsgroup, but I re-read your question. Your
problem is taking place in the server-side code:
Jeremy wrote:No, you're not.> I'm having difficulty posting a timestamp to access from client-side
> javascript using New Date().
You should not use the deprecated ODBC connection. Use the native Jet OLEDB>
> The result gives a syntax error on my INSERT INTO command on the ASP.
> If I take the Date Data out, all other data gets through just fine.
>
> ...It works up to here at the submit, where it goes to the asp...
>
> VBSCRIPT
> Timestamp = Request.form("Timestamp")
>
> set responseDB = server.createobject("ADODB.Connection")
> responseDB.open "driver={Microsoft Access Driver
> (*.mdb)};DBQ=C:\Inetpub\wwwroot\report\Application 04.mdb;UID=Admin"
provider instead. [url]www.connectionstrings.com[/url]
I don't have time to look it up right now (there is a list of reserved words>
> sqlText = "INSERT INTO Results (Timestamp)"
on [url]www.aspfaq.com[/url]), but I strongly suspect "Timestamp" is a reserved word.
If you cannot change the name of this column, then you need to surround it
with brackets when using it in a query passed by ADO:
sqlText = "INSERT INTO Results ([Timestamp])"
Jet databases (such as Access), require that dates be surrounded by hash> sqlText = sqlText & " VALUES("
> sqlText = sqlText & "'" & Timestamp & "'"
marks (#), not quotes (').
sqlText = sqlText & "#" & Timestamp & "#"
I concur with what Hannibal said, but he suggested you use a T-SQL function
(getDate()) instead of the more appropriate VBA function: Now(). So you
don't even have to pass the datetime from your form. You can simply do this,
avoiding all delimiter issues:
sqlText = sqlText & " VALUES(Now)"
I'm a little puzzled about this query. Are you just testing your ability to
insert a date, or do you really have a table called Results with a single
column called Timestamp?
Bob Barrows
Bob Barrows Guest



Reply With Quote

