Solved

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

Posted on 2009-03-31
3
564 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 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