Date Formatting Problem

T

Thomas Beyerlein

I am binding dates to a textbox, the date is stored in SQL in a datetime
field. When it gets bound it turns it into a long date (Sunday, Dec. 25
2005), in SQL when viewing the table it views as a shortdate. When
inserted to SQL the datetimepicker format for the date is short. I have
not had a problem with the formatting of a date to a textbox before, but
this time I am using the CurrencyManager to navigate though several
records. This is the code it am using to bind it to the textbox:

txtArchiveDate.DataBindings.Add("Text", myDV, "Archive_Date")


Any suggestions on how to fix this date formatting problem would be
helpful.

Thanks
Tom
 
S

stand__sure

Look at creating a Binding object and then adding that to your
Control's DataBindings

'something like this should work
Dim b As New Binding("Text", myDV, "Archive_Date")
'then either
AddHandler b.Format, AddressOf ShortDateToLongDate
'or
b.FormatString = "{0:d}"
txtArchiveDate.DataBindings.Add(b)
 
T

Thomas Beyerlein

This doesn’t work do to the fact that it is a binding and not a string.
Any other ideas
I even tried Changing the SQL to a nvarchar and it still gives me a long
date
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top