.NETGURU
Date TextBox problem
Messages   Related Types
This message was discovered on microsoft.public.dotnet.faqs.

Post a new message to this list...

KavvY
I have a TextBox where the user enters a date.

The user types in the UK format dd/mm/yyyy and its getting read from the
TextBox in US format mm/dd/yyyy. This is on a PC with English date time
format.

Is there a way of converting this?

Cheers
Rich.

Reply to this message...
 
    
Anushi
Hi Rich,
See if you can define a custom datetime format string :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcustomdatetimeformatstrings.asp

Additional reference :
DateTime best practices :
http://msdn.microsoft.com/netframework/default.aspx?pull=/library/en-us/dndotnet/html/datetimecode.asp

Hope this helps.
Regards,
Anushi

"KavvY" <k@u.r> wrote in message
news:2voNc.9039$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
KavvY
"KavvY" <k@u.r> wrote in message
news:2voNc.9039$Click here to reveal e-mail address...
[Original message clipped]

Ok so the problem isn't the text box, it seems to be something happening
after I attempt to update an SQL table.

DateTime dt = Convert.ToDateTime(tbxDateCompleted.Text);
info(dt.ToString()); // this just outputs the date to a label window

string sqlString = "UPDATE Goods_Returned " +
"SET Complaint_Justified = '" +
ddlJustified.SelectedItem.Value.ToString() + "'," +
"Date_completed = '" + dt.ToString() + "'," +
"ProductID = '" + tbxProductId.Text + "'," +
"Comments = '" + tbxComments.Text + "'," +
"Corrective_Action = '" + tbxCorrectiveAction.Text + "'," +
"Preventive_Action = '" + tbxPreventiveAction.Text + "'," +
"Reason_for_return = '" + tbxReasonForReturn.Text + "' " +
"WHERE Complaint_number = '" + tbxComplaintNo.Text + "'";

SqlCommand cmd = new SqlCommand(sqlString, sqlConnection1);
sqlConnection1.Open();
cmd.ExecuteNonQuery();
sqlConnection1.Close();

It seems that the date is getting reversed *after* the sqlString is created,
which leads me to suspect the SqlCommand class is the culprit.

Reply to this message...
 
 
System.Convert
System.Data.SqlClient.SqlCommand
System.DateTime
System.Web.UI.MobileControls.TextBox
System.Web.UI.WebControls.TextBox
System.Windows.Forms.TextBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification