Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Closed Thread
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-16-2002, 05:46 PM   PM User | #1
Hatch
New Coder

 
Join Date: Jun 2002
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Hatch is an unknown quantity at this point
Inserting Date into Access

I'm having a problem inserting the date into access.
My access field is formatted as mm/dd/yyyy.

This is what I have in my asp page.

Dim dtToday
dtToday = Date()

objRS.AddNew
objRS("Date") = dtToday
objRS.Update

Then I get this error message.

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

Anybody know what i'm doing wrong.
Thanks
Hatch is offline  
Old 07-16-2002, 07:12 PM   PM User | #2
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
I don't see a table anywhere.

<edit>
And I can't remember, but maybe you should rename your field name of "Date" to something like UserDate or PollDate or D_Date.

I think I had some type of problem like that before when I did that, Might be a totaly differnt story.
</edit>
Morgoth is offline  
Old 07-17-2002, 02:02 AM   PM User | #3
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
Can we see the insert statement? That seems to be the problem yet you didn't include that code.
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)
whammy is offline  
Old 07-20-2002, 07:58 PM   PM User | #4
BrainJar
Regular Coder

 
Join Date: Jun 2002
Posts: 185
Thanks: 0
Thanked 0 Times in 0 Posts
BrainJar is an unknown quantity at this point
I think you need to use square brackets for the column name:

objRS("[Date]") = dtToday

because "Date" is a reserved word in Access SQL.
BrainJar is offline  
Old 07-21-2002, 03:00 PM   PM User | #5
ReyN
New Coder

 
Join Date: Jun 2002
Location: Pilipinas
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
ReyN is an unknown quantity at this point
hi, try . . .

Dim dtToday
dtToday = Date

objRS.AddNew
objRS("Date") = dtToday
objRS.Update
__________________
aspxtreme
ReyN is offline  
Old 07-21-2002, 07:08 PM   PM User | #6
QuackHead
Regular Coder

 
Join Date: Jun 2002
Posts: 344
Thanks: 0
Thanked 0 Times in 0 Posts
QuackHead is an unknown quantity at this point
Quote:
Originally posted by ReyN
hi, try . . .

Dim dtToday
dtToday = Date

objRS.AddNew
objRS("Date") = dtToday
objRS.Update
This should work - Date is a function, but never has any parameters in it, therefore, it doesn't need to have the () attached at the end...

Also, what BrainJar said could also be true, try changing the column name to "theDate" or "CreationDate" or something...

~Quack
QuackHead is offline  
Old 07-22-2002, 04:47 AM   PM User | #7
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
L0L.

This is basically all I had, when I put in the date into my db.
SQL = "INSERT INTO table (tabledate) VALUES (" & Now() & ")"

I don't see a problem with it, nor would you. But at odd time, it did the little screw up I had told you.

I don't know why it happend. all it was, was a mistake for the day and month. And I fixed it by:
Month(Now()) & "/" & Day(Now()) & "/" & Year(Now()) & " " & FormatDateTime(Now(), vbLongTime)

And Whammy's idea:
default value.

I have my db's all set up to do it all 3 ways. So, if anyone of them messes up, and they are do the problem anyways, I'll post another topic.

Whammy, if it's all right with you and everyone else, this topic can be locked. I think the problem is sovled...
For Now()

Last edited by Morgoth; 07-22-2002 at 04:50 AM..
Morgoth is offline  
Old 07-22-2002, 09:37 PM   PM User | #8
ReyN
New Coder

 
Join Date: Jun 2002
Location: Pilipinas
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
ReyN is an unknown quantity at this point
if all you need is a date, use Date. if you need date and time, use Now.

NOTE: Both do not use parentheses.
__________________
aspxtreme
ReyN is offline  
Old 07-23-2002, 07:50 PM   PM User | #9
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
I am a little edgy on what "parentheses" is, but I think I'll be fine for the mean part.
Morgoth is offline  
Closed Thread

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:06 PM.


Advertisement
Log in to turn off these ads.