Solved

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

Posted on 2009-03-31
3
567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 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