Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now