Trouble sending New Date() info to Access via asp

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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',...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default 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:
    > I'm having difficulty posting a timestamp to access from client-side
    > javascript using New Date().
    No, you're not.
    >
    > 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"
    You should not use the deprecated ODBC connection. Use the native Jet OLEDB
    provider instead. [url]www.connectionstrings.com[/url]
    >
    > sqlText = "INSERT INTO Results (Timestamp)"
    I don't have time to look it up right now (there is a list of reserved words
    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])"
    > sqlText = sqlText & " VALUES("
    > sqlText = sqlText & "'" & Timestamp & "'"
    Jet databases (such as Access), require that dates be surrounded by hash
    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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139