Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
automatic insert time and date into database access
Old 10-25-2006, 11:50 AM automatic insert time and date into database access
lim888's Avatar
Novice Talker

Posts: 9
Name: Lim
Trades: 0
Greetings, I wonder how to insert the time and date into access db. I trie

sql = sql & " Insert (topic, date, time) INTO forumdata WHERE ' " & date() & " ' , ' " & time() & " ' "

I want to insert the date and time automatically whenever the user post or open a thread
lim888 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-25-2006, 12:08 PM Re: automatic insert time and date into database access
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
First of all, insert/delete/modify SQL statements don't ever have a WHERE condition in them. WHERE conditions are used with SELECT statements to filter out data.

Second, you don't actually need to use any SQL if you're using Access (although I wouldn't use it for a forum personally.)

In Access, when you define tables, you can set a Default value for any field in the table in the Design View (look at the bottom of the table design view screen...you'll see options for the various fields.

Add the following to the Default value of your date field:

=Date()

And the following to the Default value of your time field:

=Time()

And you're done. It will automatically insert the current Date and Time any time you insert a new record.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 10-25-2006, 12:26 PM Re: automatic insert time and date into database access
lim888's Avatar
Novice Talker

Posts: 9
Name: Lim
Trades: 0
sql = sql & "Insert (topic, date, time) INTO forumdata VALUES"
sql = sql & " (' " Request.Form("topic") " ',"
sql = sql & " ' " Request.Form(=date()) " ' ,"
sql = sql & " ' " Request.Form(=time()) " ' )"

Is it in such way, thank you.
lim888 is offline
Reply With Quote
View Public Profile
 
Old 10-30-2006, 11:42 AM Re: automatic insert time and date into database access
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
No. You don't need to insert date and time at all. Just the topic. The date and time will be inserted automatically.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to automatic insert time and date into database access
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14068 seconds with 12 queries