469,306 Members | 1,794 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Need help with this simple sql statement

I am trying to store the current date to an ms access database on my server.
I set it up with a dsnless connection.
Here is the statement:
Insert Into employees(timestamp) Values ('" & date() & "')"

the timestamp field is of type date/time in the ms access database.

I get an error saying the insert statement is invalid. Cannot get you the
exact error, my server is down.
But it seems that the syntax is correct.

Please advise

thanks


Jul 22 '05 #1
1 1936
Jill wrote:
I am trying to store the current date to an ms access database on my
server. I set it up with a dsnless connection.
Here is the statement:
Insert Into employees(timestamp) Values ('" & date() & "')"

the timestamp field is of type date/time in the ms access database.

I get an error saying the insert statement is invalid. Cannot get
you the exact error, my server is down.
But it seems that the syntax is correct.

Actually, it isn't. Date literals in JetSQL need to be delimited with hash
marks (#), not quotes (').

However, in this case, you should use the builtin JetSQL date() function,
rather than concatenating in te result of the vbscript date() function:

Insert Into employees(timestamp) Values (date)

Since the date function is not a literal, you don't need to delimit it.

In the future, if you do need to pass values from vbscript to queries, I
suggest using saved parameter queries:
http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl

If for some reason, you have an aversion to or are unable to use saved
parameter queries, you can use a Command object to pass parameters to sql
statements constructed in your vbscript code:
http://groups-beta.google.com/group/...e36562fee7804e

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Alex | last post: by
2 posts views Thread by Anurag | last post: by
28 posts views Thread by Vishal Naidu | last post: by
160 posts views Thread by RG | last post: by
reply views Thread by ward | last post: by
9 posts views Thread by pic078 via AccessMonster.com | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.