Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.net SQL and Dates 1

Status
Not open for further replies.

tsp1lrk

IS-IT--Management
May 30, 2001
103
US
Hello!

I'm working with ASP.net, SQL and Visual Studio.Net. I have a webform that displays the date. I want to take that date and insert it into a table in a SQL database and I can't seem to get it as a string or text that can be entered into the table- What would be the syntax on the webform itself to display the current date and then take that date and insert it into a database- I know it has to be a string or text, but I've been struggling because I'm new to ASP.net and Visual Studio- I'm using the Code-Behind page too so I'm not sure what is the correct way to do this- Any help is appreciated- I can always count on Tek-Tips for answers-

Lisa
UPS
 
Thanks very much, this is very helpful. My other question to you is what if I want to capture the date automatically; I don't want the users filling out the date; I want to show it on the page, but submit it into the database when they submit the form- Any info on that method? Thanks again- I bookmarked that information-

Lisa
 
You can get the time of day using the DateTime object:
Dim myDate as string = DateTime.Now.ToString()
TimeLabel.Text = myDate

You can then convert your myDate string back to a DateTime with

Dim myDate2 as DateTime = Ctype(myDate,DateTime)

I think this syntax should work, but the logic is correct.


regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
 
Thanks so much- I was able to get it to work!!!! Kewl... I can always count on Tek-Tips to solve my problems!!!
Lisa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top