Hello.
I am using VB.Net to connect to mysql database. Using input from textboxes to link with fields defined as type varchar work perfectly fine. However, a constant problem arises when i try to link an input from datetimepicker with a MySQL field of data type time. Whatever i try, the database time always shows 12:00:00. I had a similar problem initially with MySQL data type date. I managed to overcome the date problem using the code below:
'The function below was obtained from the following website
'http://www.vbcity.com/forums/faq.asp?fid=44&cat=SQL%20Server#TID31172
Public Shared Function DateToDB(ByVal TheDate As Date) As String
Dim str As String
With TheDate
str = (.Year.ToString.PadLeft(2, Convert.ToChar("0")) & "-" & .Month.ToString.PadLeft(2, Convert.ToChar("0")) & "-" & .Day.ToString.PadLeft(2, Convert.ToChar("0")))
End With
Return str
End Function
However this does not work with data type time. Please advise and thanking you in advance.