Search:
Namespaces
Discussions
.NET v1.1
Feedback
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
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com