Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #21984
| Message-ID | <1649164.xbWJDP9Hnm@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2013-11-12 13:21 +0100 |
| Subject | Re: Date to MS Access |
| Newsgroups | comp.lang.javascript |
| References | <j7ednQbAcdSE7BzPnZ2dnUVZ_uadnZ2d@westnet.com.au> <2514043.dTvkTq4YzN@PointedEars.de> <W-SdnWXwqfZnPxzPnZ2dnUVZ_rudnZ2d@westnet.com.au> |
Andrew Poulos wrote:
> On 12/11/2013 11:57 AM, Thomas 'PointedEars' Lahn wrote:
>> Andrew Poulos wrote:
>>> I have an MS Access field of type Date/Time with no specific format set.
>>> Here Access dates appear in this type of format
>>> 12/11/2013 7:57:46 AM
>>>
>>> I need to take a date from the client side and pass it via a posted form
>>> to an ASP page running JScript.
>>>
>>> On the client I have
>>> var nowDate = new Date();
>>>
>>> On the server I have
>>>
>>> var d = ... // nowDate retrieved from the form
>>
>> The part that is missing from your question is how you get “nowDate” into
>> the form.
>
> I added nowDate.toISOString() as a value for a hidden input.
Can you rely on a conforming implementation of ECMAScript Ed. 5 or later?
> >> var SQLstr = "UPDATE myTable " +
> >> "Set tbl_Date=#" + d +"# " +
> >> "WHERE myID=1;";
> >
> > Hopefully you clean your input so that SQL injection like
> >
> > d = "12/11/2013 7:57:46 AM#; DELETE myTable;"
> > + " UPDATE myTable SET tbl_Date=12/11/2013 7:57:46 AM";
> >
> > is prevented. The proper approach is Prepared Statements, but
> > apparently MS JetSQL does not support that; you could emulate it.
>
> Yes.
Yes to what?
>>> Running it though results in a "500: Internal Server Error".
>>>
>>> How do I "format" the date on the client so that its valid SQL for
>>> Access?
>>
>> You could use Date.prototype.strftime("%d/%m/%Y %I:%M:%S %p") as provided
>> by JSX:string/date.js [1] on the client side, but I would strongly
>> recommend to pass a timestamp (Date.prototype.getTime()) and let the
>> server-side code do the SQL formatting (in which case I would be
>> interested to know if date.js worked there if there is no ASP-native
>> way).
>
> I starting testing the Access function CDATE and passing it (yyyy-mm-d
> hours:minutes:seconds) which seems cumbersome
It also appears to be unsafe as it is still a string and code injection is
possible.
> but I'll look into using a timestamp instead.
ACK.
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Date to MS Access Andrew Poulos <ap_prog@hotmail.com> - 2013-11-12 11:05 +1100
Re: Date to MS Access Andrew Poulos <ap_prog@hotmail.com> - 2013-11-12 11:34 +1100
Re: Date to MS Access Christoph Michael Becker <cmbecker69@arcor.de> - 2013-11-12 01:35 +0100
Re: Date to MS Access Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-12 01:57 +0100
Re: Date to MS Access Andrew Poulos <ap_prog@hotmail.com> - 2013-11-12 14:38 +1100
Re: Date to MS Access Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-12 13:21 +0100
Re: Date to MS Access Andrew Poulos <ap_prog@hotmail.com> - 2013-11-12 23:42 +1100
Re: Date to MS Access "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-11 17:41 -0800
csiph-web