Solved

Insert and update date field in asp.net app using access

Posted on 2009-03-31
3
563 Views
Last Modified: 2012-06-27
I want to add a time stamp by inserting the current date when a user inserts or updates a record. This seems to be more difficult then I had expected, probably because I'm new and using Access (maybe issues with date formating).
Would it be best to have a hidden text box that get the current date in the insert item and edit item templates, or, another way. After date is updated, it will be displayed in the item template.

thanks for looking and your suggestions
alan
0
Comment
Question by:avoorheis
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
JenniQ earned 500 total points
ID: 24033209
The easiest way (but not the best practice) is to create a text field (nchar or whatever) in the access database called TimeStamp and set the value in ASP.NET to DateTime.Now().ToString()

This will print the time into the db. Then when you want to retrieve it and format, you can pull the string into a DateTime object using DateTime.Parse(string date) and write it out with DateTime.ToShortDateSTring() or whatever formatting you want.
Let me know if this helps.

-- jenni
0
 

Author Comment

by:avoorheis
ID: 24045756
Hi Jenni,
I bet this will work if I know how to format it in the updatecommand. It works ok if I just replace DateTime.Now().ToString() with 'xxx'.
UpdateCommand="UPDATE tblDisplayInventory SET SF = ?, Dated = DateTime.Now().ToString() WHERE (AccountNo = ?)">
like it is now, I get this error:
Invalid use of '.', '!', or '()'. in query expression 'DateTime.Now().ToString()'.

thanks
0
 

Author Comment

by:avoorheis
ID: 24321610
this worked
Dated = Now()
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question