I'm habing a problem with an access database i'm trying to fill programmatically with vb.net.
I have a datatimepicker to set a date with a custom format like "dd/mm/yyyy hh:mm"
If I insert this date in my access database the days and months are switched (mm/dd instead of dd/mm).
What could be causing this?
thank you for your help guys.
I've tried parameterized queries but I got a datatime mismatch error while executing the insert query.
I figured it would have been a globalisation problem.
Apparently the error occurs when I set my classes datatime to the value in a datetimepicker with custom format(dd-MM-yyyy H:mm:ss)
It is weird though: if I return a messagebox with the month of the datetimepicker value, it will return what I need, but if I set my classes datetime, it goes wrong.
I managed to solve the problem using
Dim strCurrentCulture As String = Thread.CurrentThread.CurrentCulture.ToString
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US", True)
_cls.myDateTime = DateTimePicker1.Value
Thread.CurrentThread.CurrentCulture = New CultureInfo(strCurrentCulture, False)
I'm not sure if I will run into problems on other machines with different culturesettings.
Could anyone enlighten me on this?
edit: Hmmmm.... apparently this only works now and then :(
I don't understand....